from machine import Pin
import neopixel
import time
import random
from theater_chase_effect import theater_chase
from color_wipe import color_wipe
from strobe_effect import strobe
from bounce_effect import bounce
from wave_pulse import wave_pulse
# Number of leds in the neopixel
NUM_LEDS = 16
# pin number connected to on the raspberry pi
PIN_NUM = 0
# initialize the neopixel ring led
np = neopixel.NeoPixel(Pin(PIN_NUM), NUM_LEDS)
def spinning_multi_color(wait) :
for i in range(NUM_LEDS) :
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
np[i] = (r, g, b)
np.write()
time.sleep(wait)
def rainbow_cycle(wait) :
for j in range(255) :
for i in range(NUM_LEDS) :
rc_index = (i * 256 // NUM_LEDS) + j
np[i] = wheel(rc_index & 255)
print(f"j: {j} | i: {i} | rc index : {rc_index}")
np.write()
time.sleep(wait)
def wheel(pos) :
if pos < 85 :
return (pos *3, 255 - pos, 0)
elif pos < 170 :
pos -= 85
return (255 - pos *3, 0, pos * 3)
else :
pos -= 170
return (0, pos * 3, 255 -pos *3)
while True :
# rainbow_cycle(0.1)
#theater_chase((0, 255, 0), 0.07, np, NUM_LEDS)
#color_wipe((0, 255, 0), NUM_LEDS, np, 0.02)
# strobe((255, 255, 255), 5, 0.2, np)
# bounce((0, 100, 244), 0.08, np, NUM_LEDS)
wave_pulse(color=(0, 255, 0), np=np, NUM_LEDS=16)
# while True :
# np[1] = (255, 0, 255)
# np.write()
# time.sleep(1)