How to wire an RGB LED to a Raspberry Pi Pico
To wire an RGB LED to a Raspberry Pi Pico, connect R to GP11 (physical pin 15), G to GP12 (physical pin 16), B to GP13 (physical pin 17) and C to GND. Each color has its own 220 ohm resistor, so every pin drives only a few milliamps at 3.3 V; this is a common cathode part, so HIGH lights a color. The sketch below uses no library beyond what the board includes. It steps through red, green, blue and white, printing the name of each.
- 3.3 V logic
- Library: none
- 4 wires, 3 helper parts
RGB LED to Raspberry Pi Pico wiring table
Every wire in the circuit above, with the part’s pin names and the board’s own labels. The wire colors are the ones the circuit uses; on a real bench any colors work.
| RGB LED pin | Raspberry Pi Pico pin | Wire color | Why |
|---|---|---|---|
| R (red) | GP11 (physical pin 15), through R1 (220 Ω) | red | The red anode, through its own 220 ohm resistor. The pin must be able to do PWM. |
| G (green) | GP12 (physical pin 16), through R2 (220 Ω) | green | The green anode, through its own resistor. |
| B (blue) | GP13 (physical pin 17), through R3 (220 Ω) | blue | The blue anode, through its own resistor. |
| C (common cathode) | GND | gray | The longest leg joins all three cathodes and goes to ground. |
| Three 220 ohm resistors | One in each color lead | n/a | Each color is its own LED and needs its own resistor. |
Helper parts
The extra parts in the circuit above, and where their wires go:
| From | To | Wire color |
|---|---|---|
| R1 (220 Ω) pin 1 | GP11 | red |
| R2 (220 Ω) pin 1 | GP12 | green |
| R3 (220 Ω) pin 1 | GP13 | blue |
Power and logic levels for RGB LED and Raspberry Pi Pico
Logic level
The Raspberry Pi Pico’s GPIO pins are 3.3 V logic and are not 5 V tolerant. Nothing wired to a pin may go above 3.3 V.
This pair
Each color is a separate LED behind its own 220 ohm resistor, so each pin drives only a few milliamps at 3.3 V. This is a common cathode part: HIGH lights a color. A common anode part has its long leg on VBUS (5 V from USB) and lights on LOW, so analogWrite values must be inverted.
Pins to leave alone
The numbers in the code are GP numbers, not the physical pin numbers printed beside the header: GP15 is pin 20. GP23 to GP25 are used on the board itself, and GP25 is the LED.
The working code for the Raspberry Pi Pico
Library: none, the sketch mixes the colors with analogWrite(). This is the sketch the circuit above runs.
const int RED_PIN = 11; // GP11 (physical pin 15)
const int GREEN_PIN = 12; // GP12 (physical pin 16)
const int BLUE_PIN = 13; // GP13 (physical pin 17)
void setColor(int r, int g, int b, const char* name) {
analogWrite(RED_PIN, r);
analogWrite(GREEN_PIN, g);
analogWrite(BLUE_PIN, b);
Serial.println(name);
delay(400);
}
void setup() {
Serial.begin(115200);
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
}
void loop() {
setColor(255, 0, 0, "Red");
setColor(0, 255, 0, "Green");
setColor(0, 0, 255, "Blue");
setColor(255, 255, 255, "White");
}
What you should see
The LED shows red, then green, then blue, then white, about 400 ms each, and starts again. The serial monitor, at 115200 baud, prints the name of the color as it is set.
If the colors look inverted, the part is common anode: its long leg goes to the supply, and the values in the sketch must be inverted.
The serial monitor prints this, recorded from the circuit above running for two seconds:
Red
Green
Blue
White
Red
GreenCommon mistakes wiring an RGB LED to a Raspberry Pi Pico
Using one resistor for all three colors
The three LEDs have different voltage drops, so on one shared resistor the color that drops least takes most of the current and the mix looks wrong. Give each color its own resistor.
Mixing up common cathode and common anode
A common cathode part has its long leg on ground and lights when a pin goes HIGH. A common anode part has its long leg on VBUS (5 V from USB) and lights when a pin goes LOW. With the wrong type everything looks inverted: white when you wanted off.
Choosing pins without PWM
analogWrite() only makes a smooth brightness on pins with PWM hardware. On a pin without it the color is either fully on or fully off. Every GP pin on the Pico has a PWM slice behind it.
Build your own RGB LED project
Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.