

The 5 mm RGB LED is a versatile light-emitting diode capable of producing red, green, and blue light. By combining these primary colors at varying intensities, it can generate a wide spectrum of colors. This component is widely used in decorative lighting, status indicators, displays, and DIY electronics projects. The common cathode configuration simplifies wiring by sharing a single cathode (negative terminal) for all three colors, while each color has its own anode (positive terminal) for independent control.








| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | Red | Anode for the red LED |
| 2 | Cathode | Common cathode (negative terminal) |
| 3 | Green | Anode for the green LED |
| 4 | Blue | Anode for the blue LED |
Wiring:
Controlling Colors:
PWM for Brightness Control:
Below is an example of how to connect and control the 5 mm RGB LED using an Arduino UNO:
// Define pins for RGB LED
const int redPin = 9; // Red anode connected to pin 9
const int greenPin = 10; // Green anode connected to pin 10
const int bluePin = 11; // Blue anode connected to pin 11
void setup() {
// Set RGB pins as output
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Example: Cycle through basic colors
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
delay(1000);
setColor(0, 255, 255); // Cyan
delay(1000);
setColor(255, 0, 255); // Magenta
delay(1000);
setColor(255, 255, 255); // White
delay(1000);
}
// Function to set RGB color
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue); // Set brightness for red
analogWrite(greenPin, greenValue); // Set brightness for green
analogWrite(bluePin, blueValue); // Set brightness for blue
}
LED Not Lighting Up:
Incorrect Colors or No Color Mixing:
LED Flickering:
LED Overheating:
Can I use the RGB LED without a microcontroller? Yes, you can use switches or a simple circuit with resistors to manually control the colors.
What resistor value should I use?
A 220Ω to 330Ω resistor is typically sufficient for 5V systems. Calculate the exact value using Ohm's Law:R = (V_supply - V_forward) / I_forward.
Can I control the LED with 3.3V systems? Yes, but ensure the forward voltage of each color is compatible with the 3.3V supply.