timber101

My Countdown Script

Apr 10th, 2021
470
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×