import machine
import neopixel
import time
pixel_pin = machine.Pin(4)
num_pixels = 30
favorite_colors = [
(255, 0, 0),
(0, 255, 0),
(0, 0, 255),
(255, 255, 0),
(255, 0, 255),
(0, 255, 255)
]
pixels = neopixel.NeoPixel(pixel_pin, num_pixels)
def transition_colors(color1, color2, steps):
for step in range(steps + 1):
r = int(color1[0] + (color2[0] - color1[0]) * step / steps)
g = int(color1[1] + (color2[1] - color1[1]) * step / steps)
b = int(color1[2] + (color2[2] - color1[2]) * step / steps)
pixels.fill((r, g, b))
pixels.write()
time.sleep(0.1)
while True:
for i in range(len(favorite_colors) - 1):
transition_colors(favorite_colors[i], favorite_colors[i + 1], 10)
transition_colors(favorite_colors[-1], favorite_colors[0], 10)