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()
def rainbow_cycle(wait): for j in range(255): for i in range(num_pixels): pixel_index = (i * 256 // num_pixels) + j pixels[i] = wheel(pixel_index & 255) pixels.show() time.sleep(wait)
def main(): color1 = readColor() color2 = readColor() for i in range(num_pixels): if (i % 2 == 0): pixels[i] = color1 else: pixels[i] = color2 pixels.show()
def runner(speed): #choose random color color = random_color() #make the next light change to that color with time delay for i in range(num_pixels): pixels[i] = color pixels.show() time.sleep(speed)
def selectionSort(pause): #ascending order for i in range(num_pixels): time.sleep(pause) min_i = i for j in range(i + 1, num_pixels - 1): if (value(pixels[j]) < value( pixels[min_i])): #if less than min set new min min_i = j #swap min and i swap(i, min_i) pixels.show()
def main(): fibonacci = Fibonacci() index = 0 for x in fibonacci: print(str(index) + " x: " + str(x)) color = random_color() for i in range(x): pixels[index + i] = color index = index + x pixels.show()
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)
import board import neopixel import sys from settings import num_pixels, pixels #turn LEDs off pixels.fill((0, 0, 0)) pixels.show()