from neopixel import Neopixel
from time import sleep
## Setup
NUM_LEDS = 16
LED_PIN = 6
pixels = Neopixel(NUM_LEDS, 0, LED_PIN, "GRB")
## Color Parameters
# Hue
hue_offset = 4096
# Brightness
min_brightness = 120
max_brightness = 255
breathing_speed = 10
brightness = max_brightness
brightness_up = False
## Loop
while True:
for hue in range(0, 65535, 1000):
# Breathe the brightness
if brightness_up:
brightness += breathing_speed
if brightness >= max_brightness:
brightness_up = False
else:
brightness -= breathing_speed
if brightness <= min_brightness:
brightness_up = True
# Set the hues
for led in range(NUM_LEDS):
color = pixels.colorHSV(hue + (led * hue_offset), 128, brightness)
pixels.set_pixel(led, color)
pixels.show()
sleep(0.05)
## Code for flashing the LEDs
# num_on_loops = 8
# num_off_loops = 1
# loop_count = 0
# # Flash the brightness
# if brightness is 255 and loop_count is num_on_loops:
# brightness = 0
# loop_count = 0
# elif brightness is 0 and loop_count is num_off_loops:
# brightness = 255
# loop_count = 0
# else:
# loop_count += 1