08 / 20
Make a mood lamp
Mix three PWM channels inside a frosted globe.
Run this experiment →Why it’s here
Create yellow with red and green, then try a cool blue.
How it works
Mix three PWM channels inside a frosted globe. The RGB package contains separate LEDs. Each color needs its own current-limiting path. This guided model targets the original ESP32 and Arduino-ESP32 3.x; radio, acoustics, loads and mechanics are simplified.
Try it
- Open this experiment
- Create yellow with red and green, then try a cool blue.
Connections
- GPIO 25 / 26 / 27 — Red / green / blue through separate resistors
- GND — Common cathode
Example sketch
// Common-cathode RGB LED. One resistor per color.
void setup() {
ledcAttach(25, 5000, 8);
ledcAttach(26, 5000, 8);
ledcAttach(27, 5000, 8);
}
void loop() {
ledcWrite(25, 180);
ledcWrite(26, 90);
ledcWrite(27, 220);
}Check your understanding
Why does each channel need a resistor?
Show the answer
The RGB package contains separate LEDs. Each color needs its own current-limiting path.