import time
from machine import Pin
from neopixel import Neopixel
# Constants for number of LEDs and GPIO pin number
NUM_LEDS = 16
PIN_NUM = 6
# Initialize NeoPixel strip with specified number of LEDs and GPIO pin
np = Neopixel(NUM_LEDS, 0, PIN_NUM, mode="RGB")
# Function to create a "chase" effect on the LEDs
def chase(color, wait):
for i in range(NUM_LEDS):
np.set_pixel(i, color) # Set the current LED to the specified color
np.show() # Update the LED strip
time.sleep_ms(wait) # Wait for the specified time in milliseconds
np.set_pixel(i, (0, 0, 0)) # Turn off the current LED
# Main loop
while True:
chase((255, 0, 0), 100) # Red chase effect
chase((0, 255, 0), 100) # Green chase effect
chase((0, 0, 255), 100) # Blue chase effect