Created
October 29, 2023 17:47
-
-
Save marcadams/98b635ca8d415d89ac2e14202022c63c to your computer and use it in GitHub Desktop.
Sense Hat script to flicker like a candle (for pumpkin)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sense_hat import SenseHat | |
| import time | |
| import random | |
| sense = SenseHat() | |
| colors = [ | |
| [255, 0, 0], # Red | |
| [255, 194, 0], # Amber | |
| [255, 165, 0], # Orange | |
| [0, 0, 0] # Off | |
| ] | |
| while True: | |
| interval = random.uniform(0.05, 0.1) | |
| image = [ | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), | |
| random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors), random.choice(colors) | |
| ] | |
| sense.set_pixels(image) | |
| time.sleep(interval) | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Edit crontab and add this to run on boot: @reboot python /home/pi/sense_leds.py