from machine import Pin
import time
led = Pin(2, Pin.OUT)
sswitch = Pin(4, Pin.IN)
while True:
sswitch_state = sswitch.value()
print("Switch State =", sswitch_state)
if sswitch_state == 1:
led.value(1)
else:
led.value(0)
time.sleep(0.1)