from machine import Pin, Timer
from time import sleep
led = Pin(4, Pin.OUT)
push_button = Pin(21, Pin.IN, Pin.PULL_UP)
def handler(tim0):
if push_button.value() == 0:
led.on()
print("Button is pressed")
else:
led.off()
tim0 = Timer(0)
tim0.init(period = 10, mode = Timer.PERIODIC, callback = handler)