from machine import Pin
from time import sleep
def direc(y):
    global d,m
    if d == 0:
        d=1
           
def vel(y):
    global t 
    if t ==0.1:
        t=1
    else:
        t=0.1
def mo (x):
    A0.value(int(x[0]))
    A1.value(int(x[1]))
    B0.value(int(x[2]))
    B1.value(int(x[3]))
A0=Pin(23,Pin.OUT)
A1=Pin(21,Pin.OUT)
B0=Pin(22,Pin.OUT)
B1=Pin(19,Pin.OUT)
bot1=Pin(12,Pin.IN,Pin.PULL_UP)
bot1.irq(trigger=Pin.IRQ_FALLING,handler=direc)
bot2=Pin(14,Pin.IN,Pin.PULL_UP)
bot2.irq(trigger=Pin.IRQ_FALLING,handler=vel)
reloj =["1100","0110","0011","1001"]
anti =["1001","0011","0110","1100"]
m=0
t=0.1
d=0
v=0
while(1):
    mo(reloj[m])
    m=m+1
    sleep(t)
    if m>3:
        m=0