from machine import Pin, Timer
from time import sleep_ms
led = Pin(2, Pin.OUT)
button_pin = Pin(4, Pin.IN, Pin.PULL_UP)
push_button_timer = Timer(1)
def push_button_pressed(event):
if button_pin.value() == False:
led.value(not led.value())
# else:
# led.off()
push_button_timer.init(period=50, mode = Timer.PERIODIC, callback=push_button_pressed)