Sorry für meine späte Antwort. Musste erstmal ein bisschen Abstand zu diesem Projekt nehmen.
Code: Alles auswählen
#!/usr/bin/env python
import time
from neopixel import *
# LED strip configuration:
LED_COUNT = 15 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 5 # DMA channel to use for generating signal (try 5)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
ZEIT = 800.0
FARBE = LED_BRIGHTNESS/4
FARBE2 = FARBE/4
# Define functions which animate LEDs in various ways.
def ledOff(strip, color):
for i in range((LED_COUNT)):
strip.setPixelColor(i, Color(0, 0, 0))
strip.show()
def ledKittfadein(strip, color, wait_ms=50):
for i in range(0, 255, 10):
for j in range(strip.numPixels()):
strip.setPixelColor(j, Color( i, 0, 0))
strip.show()
time.sleep(wait_ms/20000)
for i in range(255, -1, -5):
for j in range(strip.numPixels()):
strip.setPixelColor(j, Color( i, 0, 0))
strip.show()
time.sleep(wait_ms/20000)
ledOff(strip, color)
def ledKitt(strip, color, wait_ms=50):
# for x in range(1, LED_COUNT, 1):
for i in range(14, 0, -1):
y=i
strip.setPixelColor(i, color)
y=y+1
strip.setPixelColor(y, Color((FARBE), 0, 0))
strip.setPixelColor((y+1), Color((FARBE2), 0, 0))
strip.show()
time.sleep(wait_ms/ZEIT)
strip.setPixelColor((y+1), Color(0, 0, 0))
for j in range(0, 14, 1):
z=j
strip.setPixelColor(j, color)
z=z+1
strip.setPixelColor(z, Color(255, 0, 0))
strip.setPixelColor((z-1), Color((FARBE), 0, 0))
strip.setPixelColor((z-2), Color((FARBE2), 0, 0))
strip.show()
time.sleep(wait_ms/ZEIT)
strip.setPixelColor((z-1), Color(0, 0, 0))
strip.setPixelColor((z-2), Color(0, 0, 0))
# Main program logic follows:
if __name__ == '__main__':
# Create NeoPixel object with appropriate configuration.
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
# Intialize the library (must be called once before other functions).
strip.begin()
print 'Press Ctrl-C to quit.'
ledKittfadein(strip, Color(255, 0, 0))
while True:
ledKitt(strip, Color(255, 0, 0))