from machine import Pin
from utime import sleep
Disp = [
Pin(12, Pin.OUT), # A
Pin(13, Pin.OUT), # B
Pin(14, Pin.OUT), # C
Pin(15, Pin.OUT), # D
Pin(18, Pin.OUT), # E
Pin(19, Pin.OUT), # F
Pin(21, Pin.OUT) # G
]
# Common anode 7-segment display digit patterns
digits = [
[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, 1, 1, 0, 0], # 9
[0, 0, 0, 1, 0, 0, 0], # a
[1, 1, 0, 0, 0, 0, 0], # b
[0, 1, 1, 0, 0, 0, 1], # C
[1, 0, 0, 0, 0, 1, 0], # d
[0, 1, 1, 0, 0, 0, 0], # E
[0, 1, 1, 1, 0, 0, 0], # F
]
def dis_text(x):
i = 0
for d in Disp:
d.value(digits[x][i])
i = i+1
while True:
dis_text(3)
sleep(2)
for x in range(0,10):
dis_text(x)
sleep(1)
# 7-segment display layout
# A
# ---
# F | G | B
# ---
# E | | C
# ---
# D