from machine import Pin
from utime import sleep, ticks_ms
entrada = Pin(15, Pin.IN, Pin.PULL_UP)
tiempoA = 0;
switch = False;
periodo = 0;
rpm = 0
def detectado(change):
global switch
global t
global rpm
print("ok")
t = ticks_ms()
if switch==false:
periodo = t-tiempoA
tiempoA = t
rpm = (1000/periodo)*60
switch = True;
sensor.irq(handler=detectado, trigger=Pin.IRQ_FALLING)
while True:
print(rpm)