from machine import Pin
from time import sleep
luz = Pin(25, Pin.OUT)
c=0
ca=0
def detectado(change):
global c
c+=1
luz.value(1)
sleep(0.01)
luz.value(0)
sensor = Pin(15, Pin.IN, Pin.PULL_UP)
sensor.irq(handler=detectado, trigger=Pin.IRQ_FALLING)
while True:
if c != ca:
print(c)
ca = c