Last active
February 22, 2017 10:14
-
-
Save raspberrytipsnl/638dccad327eacac57243d39bf8feabc to your computer and use it in GitHub Desktop.
Demoscript NeoPixel Ring (12 led)
This file contains 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
# Demoscript NeoPixel Ring (12 led) | |
# https://raspberrytips.nl | |
import time | |
from neopixel import * | |
from random import randint | |
LEDS = 12 # Aantel LEDS | |
PIN = 18 # GPIO 18 / PIN 12 | |
BRIGHTNESS = 55 # min 0 / max 255 | |
KLEUR_R = randint(0,255) | |
KLEUR_G = randint(0,255) | |
KLEUR_B = randint(0,255) | |
def loopLed(ring, color, wait_ms): | |
for i in range(ring.numPixels()): | |
ring.setPixelColor(i,color) | |
ring.show() | |
time.sleep(wait_ms/1000.0) | |
ring.setPixelColor(i,0) | |
ring.setPixelColor(i-1,0) | |
for i in range(ring.numPixels()-1,-1,-1): | |
ring.setPixelColor(i,color) | |
ring.show() | |
time.sleep(wait_ms/1000.0) | |
ring.setPixelColor(i,0) | |
ring.setPixelColor(i+1,0) | |
def resetLeds(ring, color, wait_ms=10): | |
for i in range(ring.numPixels()): | |
ring.setPixelColor(i, color) | |
ring.show() | |
if __name__ == '__main__': | |
ring = Adafruit_NeoPixel(LEDS, PIN, 800000, 5, False, BRIGHTNESS) | |
ring.begin() | |
for t in range (0, 5, 1): | |
loopLed (ring,Color(KLEUR_G, KLEUR_R, KLEUR_B),100) | |
resetLeds (ring,Color(0,0,0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment