LED / Strip
Controlling RGB LED Module LED / Strip with STM32 Blue Pill
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 STM32 Blue Pill
Wiring
| Component pin | STM32 Blue Pill pin | Note |
|---|---|---|
| R | PA6 (PWM, through a ~220Ω resistor) | |
| G | PA7 (PWM, through a ~220Ω resistor) | |
| B | PB0 (PWM, through a ~220Ω resistor) | |
| COM | GND | Assumes common-cathode |
Swipe sideways to see every column →
- STM32duino's analogWrite() works the same way as the Arduino Uno's here — PA6/PA7/PB0 are all timer-backed PWM pins on the Blue Pill.
- Same common-cathode-vs-anode and color-balance caveats as the other boards.
- Usual Blue Pill Serial-over-USB caveat doesn't apply here since this sketch has no Serial output — just visual behavior to check.
Related Components
Related Guides & Projects
STM32 Low-Power Modes: Sleep, Stop, and Standby Explained (With Working Code)
A practical guide to STM32's three-tier low-power system — Sleep, Stop, and Standby — with working STM32duino code, measured current draw on a Blue Pill, and a battery-powered project example.
STM32 Blue Pill Pinout: Every GPIO, ADC, and Alternate Function Explained
A complete STM32F103C8T6 Blue Pill pinout reference: every GPIO port, ADC channel, timer, and communication bus mapped, plus the 5V-tolerance and clone-board considerations that affect wiring decisions.
STM32 Black Pill Pinout: Every GPIO, ADC, and Peripheral Explained
Complete STM32 Black Pill (STM32F411CEU6) pinout reference: GPIO ports, 12-bit ADC, timers/PWM, USART, SPI, I2C, and the 3.3V-only pins to watch out for.
STM32 Nucleo Pinout: Arduino Headers, Morpho Connectors, and GPIO Explained
Complete STM32 Nucleo pinout reference: Arduino-compatible headers vs ST Morpho connectors, the built-in ST-LINK debugger, ADC voltage limits, and every peripheral pin mapped.