hi i programed adafruit circut rgb strip and its changes color
import time
import board
import neopixel
# Pin where the LED strip is connected
pixel_pin = board.D6 # Adjust based on your pin
num_pixels = 20 # Adjust based on the number of LEDs on your strip
brightness = 0.2 # Brightness level, from 0 to 1.0
# Create a NeoPixel object
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=brightness, auto_write=False)
def color_wipe(color, wait):
"""Fill the strip with one color, then turn off."""
for i in range(num_pixels):
pixels[i] = color
pixels.show()
time.sleep(wait)
def rainbow_cycle(wait):
"""Draw rainbow colors across all pixels."""
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 wheel(pos):
"""Generate rainbow colors across 0-255 positions."""
if pos < 85:
return (255 - pos * 3, pos * 3, 0)
elif pos < 170:
pos -= 85
return (0, 255 - pos * 3, pos * 3)
else:
pos -= 170
return (pos * 3, 0, 255 - pos * 3)
while True:
# Wipe the strip with red color
color_wipe((255, 0, 0), 0.05)
time.sleep(1)
# Wipe the strip with blue color
color_wipe((0, 0, 255), 0.05)
time.sleep(1)
# Wipe the strip with purple color
color_wipe((128, 0, 128), 0.05)
time.sleep(1)
# Wipe the strip with indigo color
color_wipe((75, 0, 130), 0.05)
time.sleep(1)
# Run the rainbow cycle effect
rainbow_cycle(0.001)