Advertisement
timber101

My Countdown Script

Apr 10th, 2021
666
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None
  1. #!/bin/python3
  2.  
  3. from sense_hat import SenseHat
  4. from time import sleep
  5.  
  6. countdowner = SenseHat()
  7.  
  8. G = [0, 255, 0]
  9. R = [255, 0, 0]
  10. X = [0,0,0]
  11.  
  12. s = 20 # number of seconds  play with this to chnage the numbe rof dots (leds)
  13.  
  14. timer = [] #an empty list
  15.  
  16. for i in range(64):  # same as for i in range(0, 64)
  17.   if i < s:
  18.     timer.append(G)
  19.     # print(i, timer)
  20.   else:
  21.     timer.append(X)
  22.     # print(i, timer)
  23.    
  24. countdowner.set_pixels(timer)
  25. #print(timer)
  26.  
  27. for i in range(0, s):
  28.   sleep(1)
  29.   timer[i] = R
  30.   countdowner.set_pixels(timer)
  31.  
  32. for i in range(0,10):
  33.   countdowner.clear()
  34.   sleep(0.1)
  35.   countdowner.set_pixels(timer)
  36.   sleep(0.1)
  37.  
  38.  
Advertisement
RAW Paste Data Copied
Advertisement