from machine import Pin
from time import sleep
led = Pin (27, Pin.OUT)
bot = Pin (28, Pin.IN, Pin.PULL_UP)
ev = False
i = 0
def detecta(p):
global led, ev
led (not led())
ev = True
bot.irq (trigger=Pin.IRQ_FALLING,
handler=detecta)
while True:
if ev:
print ("Botão pressionado")
ev = False
print (f"Momento: {i}")
sleep (1)
i += 1