from machine import Pin
from time import sleep
A = Pin(23, Pin.OUT)
B = Pin(22, Pin.OUT)
C = Pin(21, Pin.OUT)
D = Pin(19, Pin.OUT)
E = Pin(18, Pin.OUT)
F = Pin(5, Pin.OUT)
G = Pin(17, Pin.OUT)
push_1 = Pin(12, Pin.IN, Pin.PULL_UP)
push_2 = Pin(14, Pin.IN, Pin.PULL_UP)
def contador(x):
A.value(x[0])
B.value(x[1])
C.value(x[2])
D.value(x[3])
E.value(x[4])
F.value(x[5])
G.value(x[6])
numeros = [
[1,1,1,1,1,1,0], # 0
[0,1,1,0,0,0,0], # 1
[1,1,0,1,1,0,1], # 2
[1,1,1,1,0,0,1], # 3
[0,1,1,0,0,1,1], # 4
[1,0,1,1,0,1,1], # 5
[1,0,1,1,1,1,1], # 6
[1,1,1,0,0,0,0], # 7
[1,1,1,1,1,1,1], # 8
[1,1,1,1,0,1,1] ] #9
def push_dir(p):
global direccion
direccion = (not direccion)
sleep(0.2)
def push_vel(p):
global t
t = t - 0.5
if t < 0.5:
t = 1
sleep(0.2)
push_1.irq(trigger=Pin.IRQ_FALLING,handler=push_dir)
push_2.irq(trigger=Pin.IRQ_FALLING,handler=push_vel)
direccion = 1
t = 1
n = 0
while(1):
contador(numeros[n])
if direccion == 1:
n=n+1
if n > 9:
n = 0
else:
n=n-1
if n < 0:
n = 9
sleep(t)