import time
from machine import Pin
b1=Pin(1,Pin.IN,Pin.PULL_UP)
led=Pin(0,Pin.OUT)
on=0
while True:
if b1.value()==0:
if on==1:
led.off()
time.sleep_ms(200)
on=0
else:
led.on()
on=1
time.sleep_ms(200)