from machine import Pin, PWM
import time

# GP numbers: change to match your wiring
RED_PIN = 13
GREEN_PIN = 12
BLUE_PIN = 11

red = PWM(Pin(RED_PIN))
green = PWM(Pin(GREEN_PIN))
blue = PWM(Pin(BLUE_PIN))

for channel in (red, green, blue):
    channel.freq(1000)       # 1000 on/off cycles per second

def set_color(r, g, b):
    """Set brightness of each color from 0 (off) to 255 (full)."""
    red.duty_u16(r * 257)    # 255 * 257 = 65535 (full brightness)
    green.duty_u16(g * 257)
    blue.duty_u16(b * 257)

colors = [
    ("red",     (255, 0, 0)),
    ("green",   (0, 255, 0)),
    ("blue",    (0, 0, 255)),
    ("yellow",  (255, 255, 0)),
    ("cyan",    (0, 255, 255)),
    ("magenta", (255, 0, 255)),
    ("white",   (255, 255, 255)),
    ("purple",  (128, 0, 128)),
    ("orange",  (255, 128, 0)),
]

for name, (r, g, b) in colors:
    print(name)
    set_color(r, g, b)
    time.sleep(1)

set_color(0, 0, 0)           # turn the LED off
