from machine import Pin, Timer
import time
led = Pin(19, Pin.OUT)
led_blink = Pin(22, Pin.OUT)
btm = Pin(12, Pin.IN, Pin.PULL_UP)
anterior = 0
cont = 0
timer = Timer(0)
aguarda = False
def debounce(d):
global aguarda
aguarda = False
def funcao(pin):
global aguarda
if btm.value()==0 and aguarda == False:
aguarda = True
timer.init(mode=Timer.ONE_SHOT, period=100, callback=debounce)
global cont
cont += 1
while btm.value()==0:
led.on()
led.off()
btm.irq(trigger=Pin.IRQ_RISING, handler=funcao)
while True:
if cont != anterior:
anterior = cont
print(cont)