1.测试数码管
可通过此测试程序,调整数码管管脚。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from gpiozero import LEDBoard,Button from time import sleep from signal import pause #from gpiozero.pins.pigpio import PiGPIOFactory #factory = PiGPIOFactory(host='raspberry00.local') #正向放置 DM = LEDBoard(19,11,12,20,21,13,7,16,active_high=False)#,pin_factory=factory) PX = LEDBoard(26,6,5,8,active_high=True)#,pin_factory=factory) #反向放置 #DM = LEDBoard(7,21,13,5,11,12,19,6,active_high=False) #PX = LEDBoard(8,16,20,26,active_high=True) while True : for px in PX:#轮流开启片选 px.on() for dm in DM:#轮流开启段码 dm.on() sleep(0.2) DM.off() #px.off() PX.off() sleep(1) |
2、数码管字模程序
1 2 3 4 5 6 7 8 9 10 11 12 13 |
M7G= [ (1,1,1,1,1,1,0,0),#0 (0,1,1,0,0,0,0,0),#1 (1,1,0,1,1,0,1,0),#2 (1,1,1,1,0,0,1,0),#3 (0,1,1,0,0,1,1,0),#4 (1,0,1,1,0,1,1,0),#5 (1,0,1,1,1,1,1,0),#6 (1,1,1,0,0,0,0,0),#7 (1,1,1,1,1,1,1,0),#8 (1,1,1,1,0,1,1,0),#9 (0,0,0,0,0,0,0,0),#全灭 ] |
转载请注明:徐自远的乱七八糟小站 » 20181015 4位数码管驱动