RGB LED
three colours in one, common cathode
Three LEDs (red, green, blue) in one package. By mixing intensities with PWM you get any colour.
Open the course →How it works
Inside are three separate LEDs with a shared lead. With a common cathode (the most common type) the long leg is GND, and R, G, B connect to three PWM pins through a resistor each. With ledcWrite() on each channel you give 0–255 → 16 million combinations.
Pins and wiring
| Pin | What it is | Where it connects / why |
|---|---|---|
| R | Red anode | GPIO (PWM) through 220 Ω. |
| GND (common cathode) | The longest leg | Directly to GND. |
| G | Green anode | GPIO (PWM) through 220 Ω. |
| B | Blue anode | GPIO (PWM) through 220 Ω. |
Specifications
VfR ≈ 2.0 V, G ≈ 3.1 V, B ≈ 3.1 V
Current20 mA per colour max
Typecommon cathode or common anode
Tips and typical mistakes
- If you have the "common anode" version — the long leg goes to 3V3 and the logic is inverted (255 = off).
- Red shines brighter at the same PWM — reduce it a little for a balanced white.