# Connect:
# Red to GPIO pin 26
# Green to GPIO pin 27
# Blue to GPIO pin 28
#
# Code example from:
# https://docs.sunfounder.com/projects/umsk/en/latest/04_pi_pico/pico_lesson28_rgb_module.html

from machine import Pin, PWM
from time import sleep

# Initialize PWM for each color channel of an RGB LED
red = PWM(Pin(26))  # Red channel on GPIO pin 26
green = PWM(Pin(27))  # Green channel on GPIO pin 27
blue = PWM(Pin(28))  # Blue channel on GPIO pin 28

# Set 1000 Hz frequency for all channels
red.freq(1000)
green.freq(1000)
blue.freq(1000)

# Function to set RGB LED color
def set_color(r, g, b):
    red.duty_u16(r)  # Red intensity
    green.duty_u16(g)  # Green intensity
    blue.duty_u16(b)  # Blue intensity

try:
    while True:
        set_color(65535, 0, 0)  # Red
        sleep(1)
        set_color(0, 65535, 0)  # Green
        sleep(1)
        set_color(0, 0, 65535)  # Blue
        sleep(1)
except KeyboardInterrupt:
    set_color(0, 0, 0)  # Turn off RGB LED on interrupt
$abcdeabcde151015202530354045505560fghijfghij
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
RGB Led control Raspberry PI Pico W
rgb1:R
rgb1:COM
rgb1:G
rgb1:B
r1:1
r1:2
r2:1
r2:2
r4:1
r4:2