from machine import Pin
from time import sleep

led = Pin(2, Pin.OUT)
bot = Pin(27, Pin.IN, Pin.PULL_UP)

ev = False

def detecta(p):
    global led, ev
    
    led(not led())
    ev = True
    
bot.irq(trigger= Pin.IRQ_FALLING,
        handler=detecta)

i = 0    
while True:
    if ev:
        print('Botão pressionado')
        ev = False
    print (f'Momento: {i}')
    sleep(2)
    i = i + 1