-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathneo.py
More file actions
41 lines (36 loc) · 1.29 KB
/
neo.py
File metadata and controls
41 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
import time
from neopixel import *
# LED strip configuration:
LED_COUNT = 16 # 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)
# 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()
for i in range(0, strip.numPixels()):
strip.setPixelColorRGB(i, 214, 29, 125)
strip.show()
time.sleep(0.2)
for i in range(0, strip.numPixels()):
strip.setPixelColorRGB(i, 0, 0, 0)
strip.show()
time.sleep(0.2)
for i in range(0, strip.numPixels()):
strip.setPixelColorRGB(i, 214, 29, 125)
strip.show()
time.sleep(0.2)
for i in range(0, strip.numPixels()):
strip.setPixelColorRGB(i, 0, 0, 0)
strip.show()
time.sleep(0.2)
while 1:
line = input()
print line
led, r, b, g = line
strip.setPixelColorRGB(led, r, b, g)
strip.show()