#to control an led connected to GPIO-2 with respect to the position of switch connected to GPIO-14
from machine import Pin
import time
led_pin = Pin(2, Pin.OUT)
switch_pin = Pin(14, Pin.IN)
while True:
switch_state = switch_pin.value()
if switch_state == 1:
led_pin.on()
print("LED ON")
else:
led_pin.off()
print("LED OFF")
time.sleep(0.5)