Advertisement
KRITSADA

TM1637 and microbit Running Around

Jan 27th, 2020
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. from microbit import *
  2. import tm1637
  3. tm=tm1637.TM1637(clk=pin15,dio=pin16)
  4. def servo(pin,degrees):
  5.     degrees=max(0, min(degrees, 180))
  6.     duty= degrees / 180 * 102 + 25
  7.     pin.write_analog(duty)
  8. while(1):
  9.     tm.write([0x01,0,0,0])
  10.     sleep(30)
  11.     tm.write([0,0x01,0,0])
  12.     sleep(30)
  13.     tm.write([0,0,0x01,0])
  14.     sleep(30)
  15.     tm.write([0,0,0,0x01])
  16.     sleep(30)
  17.     tm.write([0,0,0,0x02])
  18.     sleep(30)
  19.     tm.write([0,0,0,0x04])
  20.     sleep(30)
  21.     tm.write([0,0,0,0x08])
  22.     sleep(30)
  23.     tm.write([0,0,0x08,0])
  24.     sleep(30)    
  25.     tm.write([0,0x08,0,0])
  26.     sleep(30)  
  27.     tm.write([0x08,0,0,0])
  28.     sleep(30)    
  29.     tm.write([0x10,0,0,0])
  30.     sleep(30)
  31.     tm.write([0x20,0,0,0])
  32.     sleep(30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement