体验了拖一拖的流水灯,感灵活性不高,偿试一下python的编程:
代码如下:
import os
import tqmain
mylist =[0xff,0xff,0xff,0xff,0xff,0xff]
tqmain.serial_write_line("start")
while True:
mystr =[]
for i in range(0,6):
mylist[i] = mylist[i]>>1
if mylist[i] == 0x0:
mylist[i] = 0x80
myvalue = mylist[i] | 0x80 #确保可以去掉0b1
mystr.append(bin(myvalue).replace('0b1',''))
tqmain.serial_write_line(mystr[1])
value = ','.join(mystr)
tqmain.matri_strfill_display(value)
os.sleep(0.5)
上传到开发板后,实现了流水灯的效果:
python流水灯
|