from machine import Pin as pin
from time import sleep
led = pin(2,pin.OUT)
switchButton = pin(14,pin.IN,pin.PULL_UP)
while True:
value=switchButton.value()
print("Current voltage:- ",value)
'''In pull up resistor the value
will be at 1 or HIGH so after pushing button
the value will be 0 or LOW'''
if value==0:
led.on()
else:
led.off()