from machine import Pin, PWM
from time import sleep
def isrA(pin):
global cnt, servo
if canal_B.value()==0:
cnt = cnt +1
servo = servo + 1
if servo < 25:
servo=25
def isrB(pin):
global cnt, servo
if canal_A.value()==0:
cnt = cnt -1
servo = servo - 1
if servo > 125:
servo:125
canal_A = Pin(14,Pin.IN)
canal_A.irq(trigger=Pin.IRQ_FALLING, handler = isrA)
canal_B = Pin(12,Pin.IN)
canal_B.irq(trigger=Pin.IRQ_FALLING, handler = isrB)
pwm = PWM(Pin(23), freq=50)
cnt = 0
servo=75
while(1):
print(cnt)
pwm.duty(servo)