示例#1
0
from neopixel import Neopixel
from time import sleep

NUMBER_PIXELS = 2
STATE_MACHINE = 0
LED_PIN = 11

strip = Neopixel(NUMBER_PIXELS, STATE_MACHINE, LED_PIN, "GRB")

while True:

    # blink red
    for i in range(0, NUMBER_PIXELS):
        strip.set_pixel(i, (255, 0, 0))
    strip.show()
    sleep(.5)

    # blink green
    for i in range(0, NUMBER_PIXELS):
        strip.set_pixel(i, (0, 255, 0))
    strip.show()
    sleep(.5)

    # blink blue
    for i in range(0, NUMBER_PIXELS):
        strip.set_pixel(i, (0, 0, 255))
    strip.show()
    sleep(.5)
    for i in range(0, NUMBER_PIXELS):
        strip.set_pixel(i, (0, 0, 0))
    strip.show()
示例#2
0
import time
from neopixel import Neopixel

numpix = 58
pixels = Neopixel(numpix, 0, 1, "RGB")

yellow = (255, 100, 0)
orange = (255, 50, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
red = (255, 0, 0)
color0 = red

pixels.brightness(50)
pixels.fill(orange)
pixels.set_pixel_line_gradient(3, 13, green, blue)
pixels.set_pixel_line(14, 16, red)
pixels.set_pixel(20, (255, 255, 255))

while True:
    if color0 == red:
        color0 = yellow
        color1 = red
    else:
        color0 = red
        color1 = yellow
    pixels.set_pixel(0, color0)
    pixels.set_pixel(1, color1)
    pixels.show()
    time.sleep(0.1)