Skip to content

Instantly share code, notes, and snippets.

@jmb
Created September 25, 2016 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmb/02b8a0a1c7ae5e2b6d8d0103b33159ee to your computer and use it in GitHub Desktop.
Save jmb/02b8a0a1c7ae5e2b6d8d0103b33159ee to your computer and use it in GitHub Desktop.
A quick and simple demo of the APA102_Pi library which fades the entire LED strip from green through to red then blue and back to green.
#!/usr/bin/python3
import apa102
import signal
from time import sleep
numLEDs = 60
globalBrightness = 5
stepDelay = 0.1
strip = apa102.APA102(numLEDs=numLEDs, globalBrightness=globalBrightness, order='rgb') # Initialize the strip
strip.clearStrip()
# Clean up on Ctrl-C
def signal_handler(signal, frame):
print("Ctrl-C pressed, clearing the LED strip.")
strip.clearStrip()
strip.cleanup()
signal.signal(signal.SIGINT, signal_handler)
while(True):
for colour in range(255):
for pixel in range(numLEDs):
strip.setPixelRGB(pixel, strip.wheel( colour ) )
strip.show()
sleep(stepDelay)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment