# Write a micropython script to turn the seven segments a-g one after another with
# the rate of 1 second and to turn off the segments with the rate of 2 seconds repeatedly
from machine import Pin
import time
a = Pin(32, Pin.OUT)
b = Pin(33, Pin.OUT)
c = Pin(25, Pin.OUT)
d = Pin(26, Pin.OUT)
e = Pin(27, Pin.OUT)
f = Pin(14, Pin.OUT)
g = Pin(12, Pin.OUT)
led =[a,b,c,d,e,f,g]
hex_patterns = [
[1, 1, 1, 1, 1, 1, 0], # for 0
[0, 1, 1, 0, 0, 0, 0], # for 1
[1, 1, 0, 1, 1, 0, 1], # for 2
[1, 1, 1, 1, 0, 0, 1], # for 3
[0, 1, 1, 0, 0, 1, 1], # for 4
[1, 0, 1, 1, 0, 1, 1], # for 5
[1, 0, 1, 1, 1, 1, 1], # for 6
[1, 1, 1, 0, 0, 0, 0], # for 7
[1, 1, 1, 1, 1, 1, 1], # for 8
[1, 1, 1, 1, 0, 1, 1], # for 9
[1, 1, 1, 0, 1, 1, 1], # for A
[0, 0, 1, 1, 1, 1, 1], # for B
[1, 0, 0, 1, 1, 1, 0], # for C
[0, 1, 1, 1, 1, 0, 1], # for D
[1, 0, 0, 1, 1, 1, 1], # for E
[1, 0, 0, 0, 1, 1, 1], # for F
]
while True:
for i in hex_patterns:
for j in range(len(led)):
led[j].value(i[j])
time.sleep(1)
for pin in led:
pin.value(0)
time.sleep(2)