示例#1
0
def main():
    while True:
        for i in range(num_pixels):
            pixels[i] = [255, 0, 0]  #set red
        pixels.show()
        time.sleep(0.4)  #pause
        pixels.fill([0, 0, 0])  #clear
        pixels.show()
示例#2
0
def main():
    #set speed of runner in seconds
    speed = 0.05

    #set all pixels to the same random color
    pixels.fill(random_color())

    #run runner until user breaks loop
    while True:
        runner(speed)
示例#3
0
def shoot():
    #make all one color
    background = random_color()
    pixels.fill(background)
    pixels.show()

    #initialize shooter
    length = 10  #length of bullet (LEDs)
    color = random_color()
    change_color(0, length, color)

    #shoot pixel
    for i in range(length, num_pixels - length + 1):
        change_color(i, length, color)  #move bullet
        change_color(i - length, length, background)  #delete path of bullet
        pixels.show()
        time.sleep(0.2)
示例#4
0
import board
import neopixel
import sys
from settings import num_pixels, pixels

#turn LEDs off
pixels.fill((0, 0, 0))
pixels.show()
示例#5
0
import board
import neopixel
from settings import num_pixels, pixels

i = input("Enter a color (as R, G, B): ")
color = tuple(int(x) for x in i.split(","))
pixels.fill(color)
pixels.show()
示例#6
0
import board
import neopixel
import numpy as np
from settings import num_pixels, pixels

#turn all lights off
pixels.fill((0, 0, 0))
pixels.show()

#take input percentage
percentage = int(
    input(
        "Enter the percent of lights on as an integer from 0 to 100: ")) / 100
i = input("Enter the primary color (as R, G, B): ")
color = tuple(int(x) for x in i.split(","))
i = input("Enter the secondary color (as R, G, B): ")
color2 = tuple(int(x) for x in i.split(","))

pixels.fill(color2)

for i in range(int(percentage * num_pixels)):
    r = np.random.randint(num_pixels)
    if (pixels[r] != color):  #if not already on turn it on
        pixels[r] = color
    else:
        i -= 1

pixels.show()