from machine import Pin
from time import sleep_ms, ticks_ms, ticks_diff
pines = [26, 27, 14, 12, 13, 25, 23]
segmentos = [Pin(pin, Pin.OUT) for pin in pines]
uni= Pin(19,Pin.OUT)
dec= Pin(18,Pin.OUT)
boton = Pin(5, Pin.IN, Pin.PULL_DOWN)
matriz = [
[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, 1, 0], # 7
[1, 1, 1, 1, 1, 1, 1], # 8
[1, 1, 1, 1, 0, 1, 1], # 9
]
tiempo = ticks_ms()
unidades = 0
decena = 0
contador = 0
def num(fila):
for columna in range(7):
segmentos[columna].value(matriz[fila][columna])
sleep_ms(200)
def conmutar(valor):
uni.value(valor)
dec.value(1-valor)
while True:
actual = boton.value() == True
if actual and not anterior:
contador = (contador + 1)%100
decena= contador//10
unidades= contador % 10
anterior = actual
conmutar(1)
num(decena)
conmutar(0)
num(unidades)
tiempo = ticks_ms()