from machine import Pin
import time
SW = Pin(4, Pin.IN, Pin.PULL_UP)
LED = Pin(5, Pin.OUT)
State = False
while True:
if SW.value()==0:
time.sleep(0.1)
if SW.value()==0:
State =not State
LED.value(State)
else :
print ("Press and hold")
LED.value(False)
time.sleep(0.1)