コード例 #1
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)
コード例 #2
0
from utime import sleep
from neopixel import Neopixel

NEOPIXEL_PIN = 0
NUMBER_PIXELS = 72
strip = Neopixel(NUMBER_PIXELS, 0, NEOPIXEL_PIN, "GRB")
left = 0
max_index = NUMBER_PIXELS - 1
step = 3

delay = .001
while True:
    print('red to green')
    for i in range(0, 255, step):
        strip.brightness(i)
        strip.set_pixel_line_gradient(0, max_index, (255, 0, 0), (0, 255, 0))
        strip.show()
        sleep(delay)
    for i in range(255, 0, -step):
        strip.brightness(i)
        strip.set_pixel_line_gradient(0, max_index, (255, 0, 0), (0, 255, 0))
        strip.show()
        sleep(delay)

    print('green to blue')
    for i in range(0, 255, step):
        strip.brightness(i)
        strip.set_pixel_line_gradient(0, max_index, (0, 255, 0), (0, 0, 255))
        strip.show()
        sleep(delay)
    for i in range(255, 0, -step):