Exemplo n.º 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()
Exemplo n.º 2
0
import machine, neopixel, time
# Set the pin number and number of pixels
from neopixel import Neopixel

NEOPIXEL_PIN = 0
NUMBER_PIXELS = 144
strip = Neopixel(NUMBER_PIXELS, 0, 0, "GRB")

# blink the first pixel red

while True:
    # set pixel 0 to be red
    strip.set_pixel(0,(255,0,0))
    strip.show()
    time.sleep(0.5)
    # turn pixel 0 off
    strip.set_pixel(0, (0,0,0))  
    
    # set pixel 1 to be green
    strip.set_pixel(1,(0,255,0))
    strip.show()
    time.sleep(0.5)
    # turn pixel 0 off
    strip.set_pixel(1, (0,0,0))
     
    # set pixel 2 to be blue
    strip.set_pixel(2,(0,0,255))
    strip.show()
    time.sleep(0.5)
    # turn pixel 0 off
    strip.set_pixel(2, (0,0,0))
Exemplo n.º 3
0
import time

from neopixel import Neopixel
# https://github.com/blaz-r/pi_pico_neopixel

numpix = 12
strip = Neopixel(numpix, 0, 0, "GRB")
# strip.brightness(50)

red = (255, 0, 0)
orange = (255, 165, 0)
yellow = (255, 255, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
indigo = (75, 0, 130)
violet = (138, 43, 226)
colors = (red, orange, yellow, green, blue, indigo, violet)

strip.brightness(255)

while True:
    for color in colors:
        for i in range(numpix):
            strip.set_pixel(i, color)
            strip.show()
            time.sleep(0.1)
            
Exemplo n.º 4
0
import machine, neopixel
from utime import sleep
from neopixel import Neopixel

NEOPIXEL_PIN = 16
NUMBER_PIXELS = 10
strip = Neopixel(NUMBER_PIXELS, 0, NEOPIXEL_PIN, "GRB")
strip.brightness(100)


def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        return (0, 0, 0)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0)
    if pos < 170:
        pos -= 85
        return (0, 255 - pos * 3, pos * 3)
    pos -= 170
    return (pos * 3, 0, 255 - pos * 3)


def rainbow_cycle(wait):
    for j in range(255):
        for i in range(NUMBER_PIXELS):
            rc_index = (i * 256 // NUMBER_PIXELS) + j
            pixels[i] = wheel(rc_index & 255)
        pixels.write()
from neopixel import Neopixel
from machine import Pin
from random import choice
from time import sleep

np = Neopixel(Pin(4), 8)


def val_gen():
  yield choice(range(255))


def color_gen():
  yield tuple(next(val_gen()) for i in range(3))


while True:
  np[choice(range(8))] = next(color_gen())
  sleep(0.5)
Exemplo n.º 6
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)