from machine import Pin
from machine import Timer
import time
led1 = Pin(5, Pin.OUT)#f
led2 = Pin(4, Pin.OUT)#e
led3 = Pin(0, Pin.OUT)#d
led4 = Pin(2, Pin.OUT)#c
led5 = Pin(14, Pin.OUT)#b
led6 = Pin(15, Pin.OUT)#a
led7 = Pin(13, Pin.OUT)#g
led_s1 = Pin(16, Pin.OUT)
led_S2 = Pin(12, Pin.OUT)
timer0 =Timer(0)
t=1
def led_s(timer0):
global t
if t == 1:
led_S2.on()
if k1 != 0:
seg(k1)
led_s1.off()
if t == 2:
led_s1.on()
seg(k2)
led_S2.off()
if t == 2:
t=1
else:
t = t + 1
def seg(n):
if n == 0:
led1.off()
led2.off()
led3.off()
led4.off()
led5.off()
led6.off()
led7.on()
if n == 1:
led1.on()
led2.on()
led3.on()
led4.off()
led5.off()
led6.on()
led7.on()
if n == 2:
led1.on()
led2.off()
led3.off()
led4.on()
led5.off()
led6.off()
led7.off()
if n == 3:
led1.on()
led2.on()
led3.off()
led4.off()
led5.off()
led6.off()
led7.off()
if n == 4:
led1.off()
led2.on()
led3.on()
led4.off()
led5.off()
led6.on()
led7.off()
if n == 5:
led1.off()
led2.on()
led3.off()
led4.off()
led5.on()
led6.off()
led7.off()
if n == 6:
led1.off()
led2.off()
led3.off()
led4.off()
led5.on()
led6.off()
led7.off()
if n == 7:
led1.on()
led2.on()
led3.on()
led4.off()
led5.off()
led6.off()
led7.on()
if n == 8:
led1.off()
led2.off()
led3.off()
led4.off()
led5.off()
led6.off()
led7.off()
if n == 9:
led1.off()
led2.on()
led3.off()
led4.off()
led5.off()
led6.off()
led7.off()
if n == 10:
led1.on()
led2.on()
led3.on()
led4.on()
led5.on()
led6.on()
led7.on()
timer0.init(period=999, freq = 200, mode = Timer.PERIODIC, callback = led_s)
global k1
global k2
k=0
while True:
k=k+1
if k == 100:
k=0
k1 = k//10
k2 = k - k1*10
time.sleep(1)