Created
September 25, 2016 09:06
-
-
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.
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
#!/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