from machine import Pin
from time import sleep
botao = Pin(1,Pin.IN,Pin.PULL_UP)
display_unidade = [
Pin(2, Pin.OUT), # A
Pin(3, Pin.OUT), # B
Pin(4, Pin.OUT), # C
Pin(5, Pin.OUT), # D
Pin(6, Pin.OUT), # E
Pin(7, Pin.OUT), # F
Pin(8, Pin.OUT) # G
]
display_dezena = [
Pin(9, Pin.OUT), # A
Pin(10, Pin.OUT), # B
Pin(11, Pin.OUT), # C
Pin(12, Pin.OUT), # D
Pin(13, Pin.OUT), # E
Pin(14, Pin.OUT), # F
Pin(15, Pin.OUT) # G
]
display_centena = [
Pin(16, Pin.OUT), # A
Pin(17, Pin.OUT), # B
Pin(18, Pin.OUT), # C
Pin(19, Pin.OUT), # D
Pin(20, Pin.OUT), # E
Pin(21, Pin.OUT), # F
Pin(22, Pin.OUT) # G
]
# Common anode 7-segment display digit patterns
digitos = [
[0, 0, 0, 0, 0, 0, 1], # 0
[1, 0, 0, 1, 1, 1, 1], # 1
[0, 0, 1, 0, 0, 1, 0], # 2
[0, 0, 0, 0, 1, 1, 0], # 3
[1, 0, 0, 1, 1, 0, 0], # 4
[0, 1, 0, 0, 1, 0, 0], # 5
[0, 1, 0, 0, 0, 0, 0], # 6
[0, 0, 0, 1, 1, 1, 1], # 7
[0, 0, 0, 0, 0, 0, 0], # 8
[0, 0, 0, 0, 1, 0, 0] # 9
]
numero=0
pausa=False
while True:
if botao.value()==0:
pausa=not(pausa)
if not(pausa):
print("contando")
centena = numero//100
dezena = (numero-centena*100)//10
unidade = numero%10
for led in range(7):
display_unidade[led].value(digitos[unidade][led])
for led in range(7):
display_dezena[led].value(digitos[dezena][led])
for led in range(7):
display_centena[led].value(digitos[centena][led])
sleep(0.25)
numero=numero+1
if numero == 100:
numero = 0
else:
print("pausado")
sleep(0.25)
sleep(0.25)