

The 5 mm RGB LED, Common Cathode, is a versatile light-emitting diode that combines red, blue, and green LEDs into a single package. This component allows users to create a wide range of colors by varying the intensity of each LED. The "common cathode" configuration means that all three LEDs share a single cathode (negative) pin, while the anodes (positive pins) are separate for each color.








| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | Red (R) | Positive terminal for the red LED |
| 2 | Cathode | Common negative terminal for all LEDs |
| 3 | Blue (B) | Positive terminal for the blue LED |
| 4 | Green (G) | Positive terminal for the green LED |
Below is an example of how to connect and control the 5 mm RGB LED using an Arduino UNO.
// Define the RGB LED pins
const int redPin = 9; // Red LED connected to pin D9
const int bluePin = 10; // Blue LED connected to pin D10
const int greenPin = 11; // Green LED connected to pin D11
void setup() {
// Set the RGB pins as outputs
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
// Example: Cycle through red, green, and blue colors
setColor(255, 0, 0); // Red
delay(1000); // Wait 1 second
setColor(0, 255, 0); // Green
delay(1000); // Wait 1 second
setColor(0, 0, 255); // Blue
delay(1000); // Wait 1 second
}
// Function to set the RGB LED color
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue); // Set red brightness (0-255)
analogWrite(greenPin, greenValue); // Set green brightness (0-255)
analogWrite(bluePin, blueValue); // Set blue brightness (0-255)
}
LED Not Lighting Up:
Incorrect Colors:
LED Flickering:
LED Overheating:
Q: Can I use the RGB LED without a microcontroller?
A: Yes, you can use switches or potentiometers to manually control the brightness of each LED.
Q: How do I create custom colors?
A: Use PWM to adjust the brightness of each LED. For example, setting red to 128, green to 64, and blue to 255 will create a unique color.
Q: Can I connect the RGB LED directly to a power source?
A: No, always use current-limiting resistors to prevent damage to the LEDs.
Q: What happens if I reverse the polarity?
A: The LED will not light up, but it is unlikely to be damaged unless excessive voltage is applied. Always double-check the pin configuration.