import time # Importing time module for adding delays
from neopixel import Neopixel # Importing Neopixel library for controlling the LED strip
# Initializing a Neopixel object with 16 LEDs, using GPIO 0, 8 bits per pixel, and "RGB" color order
pixels = Neopixel(16, 0, 8, "RGB")
colors = [
(0, 255, 0), # Green
(255, 0, 0), # Red
(0, 0, 255), # Blue
]
# Initializing pixel and color index to 0
pixel_index = 0
color_index = 0
# Infinite loop to cycle through pixels and colors
while True:
pixels.set_pixel(pixel_index, colors[color_index]) # Set the current pixel to the current color
pixels.show() # Update the LED strip to reflect changes
pixel_index += 1 # Move to the next pixel
if pixel_index == 16: # If all 16 pixels have been updated, reset
pixel_index = 0
color_index = (color_index + 1) % 3 # Move to the next color in the list, cycling through 3 colors
time.sleep(0.1) # Small delay of 0.1 seconds before moving to the next pixel