About Lesson
from time import sleep
from machine import Pin , PWM
segA = Pin(10,Pin.OUT , value = 1 )
segB = Pin(11,Pin.OUT , value = 1)
segC = Pin(12,Pin.OUT , value = 1)
segD = Pin(13,Pin.OUT , value = 1)
segE = Pin(14,Pin.OUT , value = 1)
segF = Pin(15,Pin.OUT , value = 1)
segG = Pin(16,Pin.OUT , value = 1)
buzzer = Pin(17,Pin.OUT)
son = PWM(buzzer)
son.freq(4000)
def bip():
son.duty_u16(60000)
sleep(0.1)
son.duty_u16(0)
def zero():
segA.off()
segB.off()
segC.off()
segD.off()
segE.off()
segF.off()
segG.on()
def one():
segA.on()
segB.off()
segC.off()
segD.on()
segE.on()
segF.on()
segG.on()
def two():
segA.off()
segB.off()
segC.on()
segD.off()
segE.off()
segF.on()
segG.off()
def three():
segA.off()
segB.off()
segC.off()
segD.off()
segE.on()
segF.on()
segG.off()
def four():
segA.on()
segB.off()
segC.off()
segD.on()
segE.on()
segF.off()
segG.off()
def five():
segA.off()
segB.on()#
segC.off()
segD.off()
segE.on()#
segF.off()
segG.off()
def six():
segA.off()
segB.on()
segC.off()
segD.off()
segE.off()
segF.off()
segG.off()
def seven():
segA.off()
segB.off()
segC.off()
segD.on()
segE.on()
segF.on()
segG.on()
def eight():
segA.off()
segB.off()
segC.off()
segD.off()
segE.off()
segF.off()
segG.off()
def nine():
segA.off()
segB.off()
segC.off()
segD.off()
segE.on()
segF.off()
segG.off()
for x in range(10):
Pin(x,Pin.OUT)
while 1 :
zero()
Pin(0).on()
sleep(0.5)
Pin(0).off()
bip()
one()
Pin(1).on()
sleep(0.5)
Pin(1).off()
bip()
two()
Pin(2).on()
sleep(0.5)
Pin(2).off()
bip()
three()
Pin(3).on()
sleep(0.5)
Pin(3).off()
bip()
four()
Pin(4).on()
sleep(0.5)
Pin(4).off()
bip()
five()
Pin(5).on()
sleep(0.5)
Pin(5).off()
bip()
six()
Pin(6).on()
sleep(0.5)
Pin(6).off()
bip()
seven()
Pin(7).on()
sleep(0.5)
Pin(7).off()
bip()
eight()
Pin(8).on()
sleep(0.5)
Pin(8).off()
bip()
nine()
Pin(9).on()
sleep(0.5)
Pin(9).off()
bip()
Join the conversation