from time import sleepfrom rpi_TM1638 import TMBoards# my GPIO settings (connected on GPIO19 and GPIO13 for DataIO and Clock; and on GPIO6 for the STB)DIO =19CLK =13STB =6,# instanciante my TMboardsTM =TMBoards(DIO, CLK, STB, 0)TM.clearDisplay()# 逐一顯示上方八個LED燈for i inrange(8): TM.leds[i]=True# turn on led 0 (1st led of the 1st board)sleep(0.5) TM.leds[i]=FalseTM.segments[0]='12.3'# 從第0個開始顯示資料值TM.segments[4]='56.78'# 從第4個開始顯示資料值# 第3個7節LED逐一顯示for i inrange(8): TM.segments[3, i]=Truesleep(0.5) TM.segments[3, i]=FalseTM.clearDisplay()TM.segments[0]='00000000'# 依照按鈕按下位址顯示1,沒按下顯示0whileTrue: a = TM.getData(0)print(a) seg =0 disp =''for x in a:if x ==1or x ==16:if x ==16: seg =4 disp +='1'else: disp +='0' TM.segments[seg]= dispsleep(0.5) TM.segments[seg]='0000'