from machine import Pin
from time import sleep
botao = Pin(21,Pin.IN,Pin.PULL_UP)
while True:
if botao.value():
print("solto")
display_segmentos.off()
else:
print("apertou")
di.on()
sleep(0.25)
display_segmentos = [
Pin(0, Pin.OUT),
Pin(1, Pin.OUT), # A
Pin(2, Pin.OUT), # B
Pin(3, Pin.OUT), # C
Pin(4, Pin.OUT), # D
Pin(13, Pin.OUT), # E
Pin(14, Pin.OUT), # F
Pin(15, Pin.OUT) # G
]
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
]
while True:
for numero in range(10):
for led in range(7):
display_segmentos[led].value(digitos[numero][led])
sleep(0.5)