Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###เฉลยโจทย์ 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement