KRITSADA icon

VEC Excercise microbit Running On TM1637

KRITSADA | PRO | 01/27/20 01:13:36 PM UTC | 0 ⭐ | 1212 👁️ | Never ⏰ | []
Python |

730 B

|

None

|

0 👍

/

0 👎

###เฉลยโจทย์ LED วิ่งไล่กันด้วย TM1637 และ 7 Segment
##4 เขียนโค้ดไฟวิ่งอย่างง่ายผ่าน TM1637  
 
from microbit import *
import tm1637
tm=tm1637.TM1637(clk=pin15,dio=pin16)
x=[[0x01,0,0,0],[0,0x01,0,0],[0,0,0x01,0],[0,0,0,0x02],[0,0,0,0x04],[0,0,0,0x08],[0,0,0x08,0],[0,0x08,0,0],[0x08,0,0,0],[0x10,0,0,0],[0x20,0,0,0]]
a=True
while(1):
    if button_a.was_pressed():
        if a:   a=False
        else: a=True
    for i in range(0,11):
        if a:
            tm.write(x[10-i])
        else:
            tm.write(x[i])
        if button_b.was_pressed():
            while not button_b.was_pressed():pass
        sleep(100)

Comments