Advertisement
Tylon

ThePiHut Xmas Tree No 2

Dec 12th, 2017
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. from gpiozero import LEDBoard
  2. from time import sleep
  3. from signal import pause
  4. treelights=[ 18, 5, 9, 11, 21, 10, 7, 12, 6, 1,14, 3, 20, 24, 13, 15,2, 17, 16, 23,8, 22, 4, 19 ]
  5.  
  6. treemap={ 1:4, 7:5, 16:6, 22:7, 6:8 , 14:9, 8:10, 21:11, 15:12, 3:13, 19:14, 2:15, 9:16, 10:17, 20:18, 18:19,17:20, 4:21, 24:22, 23:23, 13:24, 5:25, 12:26, 11:27
  7. }
  8.  
  9. leds=LEDBoard(*range(4,28), pwm=True)
  10.  
  11. def labelToPin(l):
  12.     return treemap[l]
  13.  
  14. def toBoard(l):
  15.     return labelToPin(l)-4
  16.  
  17. while True:
  18.     for i in treelights:
  19.         sleep(0.1)
  20.         leds.on(toBoard(i))
  21.  
  22. for i in treelights:
  23.     sleep(0.1)
  24.     leds.off(toBoard(i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement