🌈 RGB LED Mixer Using Single RGB LED (Common Cathode Type) -NANO
💡 Project Overview
In this project, we’ll build an RGB LED color mixer using a single 4-pin RGB LED and an Arduino Nano (or Uno).
By controlling the brightness of the Red, Green, and Blue channels using PWM (Pulse Width Modulation), we can blend them to create almost any color — yellow, cyan, magenta, white, and more!
This is a fun beginner project to understand color mixing and how Arduino can vary light intensity digitally.
🧩 Components Required
| Component | Quantity | Description |
|---|---|---|
| Arduino Nano / Uno | 1 | Microcontroller board |
| RGB LED (4-pin, Common Cathode) | 1 | Red, Green, Blue LEDs inside one package |
| 220 Ω Resistors | 3 | Current-limiting resistors for each color |
| Breadboard | 1 | For assembling the circuit |
| Jumper Wires | — | Male-to-male wires for connections |
⚙️ How the RGB LED Works
An RGB LED has four pins — one common cathode (GND) and three separate color pins:
- R (Red)
- G (Green)
- B (Blue)
By sending different PWM signals (0–255) from the Arduino to each color pin, we control the brightness of each internal LED.
When the lights blend, they form new colors.
| Color | Red | Green | Blue |
|---|---|---|---|
| Red | 255 | 0 | 0 |
| Green | 0 | 255 | 0 |
| Blue | 0 | 0 | 255 |
| Yellow | 255 | 255 | 0 |
| Cyan | 0 | 255 | 255 |
| Magenta | 255 | 0 | 255 |
| White | 255 | 255 | 255 |
🧭 Pin Identification of RGB LED
When you look at the LED from the flat edge side,
the pins are usually arranged as follows (from left to right):
1️⃣ Red | 2️⃣ Common (Longest Leg – GND) | 3️⃣ Green | 4️⃣ Blue
If the longest leg connects to GND, it’s a Common Cathode RGB LED — exactly what we’re using here.
🔌 Circuit Diagram & Connections
Table: Arduino to RGB LED Connections
| Arduino Pin | RGB LED Pin | Connection Through | Description |
|---|---|---|---|
| D9 | Red | 220 Ω resistor | Controls red brightness |
| D10 | Green | 220 Ω resistor | Controls green brightness |
| D11 | Blue | 220 Ω resistor | Controls blue brightness |
| GND | Longest (common) leg | — | Common Cathode (Ground) |
Text-Based Circuit View
(Flat edge)
[RGB LED]
| | | |
R COM G B
| | | |
220Ω | 220Ω 220Ω
| | | |
D9 GND D10 D11
💡 Each color pin gets its own resistor before connecting to the Arduino PWM pins.
Circuit Diagram
💻 Arduino Code (Tested for Common Cathode)
// RGB LED Mixer using Single RGB LED (Common Cathode Type)
// Arduino Nano / Uno
int redPin = 9; // Red pin of RGB LED
int greenPin = 10; // Green pin of RGB LED
int bluePin = 11; // Blue pin of RGB LED
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
setColor(255, 0, 0); // Red
delay(1000);
setColor(0, 255, 0); // Green
delay(1000);
setColor(0, 0, 255); // Blue
delay(1000);
setColor(255, 255, 0); // Yellow (Red + Green)
delay(1000);
setColor(0, 255, 255); // Cyan (Green + Blue)
delay(1000);
setColor(255, 0, 255); // Magenta (Red + Blue)
delay(1000);
setColor(255, 255, 255); // White (All colors ON)
delay(1000);
setColor(0, 0, 0); // OFF
delay(1000);
}
void setColor(int red, int green, int blue) {
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
🧠 How the Code Works
- PWM Output: The pins 9, 10, and 11 are PWM-enabled, allowing brightness control from 0 (off) to 255 (full).
setColor()Function: Simplifies color selection by taking 3 brightness values.- Color Cycle: The LED cycles through primary and mixed colors every second.
- Result: Smooth color transitions that demonstrate additive color mixing.
🌟 Expected Output
Once you power up the Arduino Nano:
- The single RGB LED will glow in Red → Green → Blue → Yellow → Cyan → Magenta → White → OFF sequence.
- Each color blends perfectly inside the LED’s body — creating a smooth light-mixing effect.
🚀 Extensions and Ideas
- Add three potentiometers to control each color manually (analog input).
- Use a Bluetooth module (HC-05) to change colors from a smartphone.
- Create a fading rainbow effect by gradually increasing/decreasing brightness in loops.
- Combine with sound or light sensors for reactive lighting effects.
✅ Summary
| Feature | Details |
|---|---|
| LED Type | 4-pin RGB LED (Common Cathode) |
| Common Pin Connection | GND |
| Arduino Pins Used | D9 (Red), D10 (Green), D11 (Blue) |
| Resistors | 220 Ω each |
| Power Supply | 5 V from Arduino |
| Code Type | PWM control with color mixing |
Pingback: Arduino Demo Kit Projects - Motion Demo Kit (With Arduino) - Project List - EDGENext Learning