from machine import Pin
from time import sleep
led = Pin(2, Pin.OUT)
bot = Pin(27, Pin.IN, Pin.PULL_DOWN)
i = 0
ev = False
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(2)
i += 1