import machine
import neopixel
import time

# Configuration
PIN = 2  # Pin where the NeoPixel is connected
NUMPIXELS = 16  # Number of pixels in the NeoPixel ring
BRIGHTNESS = 128  # Set brightness to 50% (0-255 scale)

# Initialize NeoPixel
np = neopixel.NeoPixel(machine.Pin(PIN), NUMPIXELS)

def set_color(r, g, b):
    """Set the color of all pixels in the NeoPixel ring."""
    for i in range(NUMPIXELS):
        np[i] = (int(r * BRIGHTNESS / 255), int(g * BRIGHTNESS / 255), int(b * BRIGHTNESS / 255))
    np.write()

def orange_to_white_transition(wait):
    """Transition from orange to white."""
    # Transition from orange to white
    for i in range(256):
        set_color(i, 165, 0)  # Orange (R: i, G: 165, B: 0)
        time.sleep(wait)
    for i in range(256):
        set_color(255, 255, 255)  # White (R: 255, G: 255, B: 255)
        time.sleep(wait)

# Main loop
while True:
    orange_to_white_transition(0.05)  # Adjust the speed of the transition