LED / Strip
Controlling RGB LED Module LED / Strip with Raspberry Pi
What is the RGB LED Module?
RGB LED Module practical reference
A basic 4-pin RGB LED breakout used for teaching PWM color mixing and simple status-indicator projects.
Key specifications
- Type: Common-cathode on most breakout modules (common-anode variants also exist — verify with a multimeter before wiring)
- Forward voltage: ~2V (Red), ~3.2V (Green), ~3.2V (Blue), typical
- Control: 3 independent PWM channels, one per color, each through its own current-limiting resistor
- Current-limiting resistor: ~220Ω-330Ω per color channel at 5V logic — a shared value across R/G/B works fine even though forward voltages differ slightly
Pinout and connection notes
On a common-anode module, drive each color LOW to turn it on rather than HIGH — inverted from the common-cathode wiring most beginner tutorials assume.
- R: Red channel — through a current-limiting resistor to a PWM pin
- COM: Common cathode (to GND) or common anode (to VCC), depending on your specific module
- G: Green channel — through a current-limiting resistor to a PWM pin
- B: Blue channel — through a current-limiting resistor to a PWM pin
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up RGB LED Module with Raspberry Pi
Library
gpiozero
Usually preinstalled on Raspberry Pi OS; otherwise: pip3 install gpiozero
Wiring
| Component pin | Raspberry Pi pin | Note |
|---|---|---|
| R | GPIO17 (through a ~220Ω resistor) | |
| G | GPIO27 (through a ~220Ω resistor) | |
| B | GPIO22 (through a ~220Ω resistor) | |
| COM | GND | Assumes common-cathode |
Swipe sideways to see every column →
- gpiozero's RGBLED assumes common-cathode by default — pass active_high=False when constructing it if your module is common-anode instead.
- Color values here are 0.0-1.0 floats, not 0-255 integers like the microcontroller examples — a common mix-up when porting example code between boards.
- Same color-balance caveat as the other boards: equal 1.0/1.0/1.0 doesn't necessarily look like true white on a given module.
Related Components
Related Guides & Projects
Raspberry Pi Pico W and Pico 2 W: Install MicroPython with Thonny or UF2
Hold BOOTSEL, drag the correct UF2 file, open the REPL and blink the onboard LED. Includes the Pico vs Pico W vs Pico 2 W firmware differences and what to do when the drive does not appear.
Raspberry Pi Pico W Web Server in MicroPython: Control an LED and Read a Sensor
Connect the Pico W to WiFi, serve a responsive control page, switch an LED and display the onboard temperature or an external sensor, with timeouts and reconnect handling.
Raspberry Pi Pico Oscilloscope with MicroPython
Convert a Raspberry Pi Pico into a basic 500 kSPS oscilloscope using its 12-bit ADC and MicroPython. Displays waveforms on an SSD1306 OLED or streams samples over USB serial to a Python plotter on your PC.
Self-Hosted Nextcloud NAS on Raspberry Pi 4
Build a private, durable Nextcloud NAS on a Raspberry Pi 4 -- SSD boot instead of a failure-prone SD card, Docker Compose with Redis caching, Tailscale for remote access with zero ports forwarded, and an automated backup strategy that actually runs.