

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








| Pin Number | Name | Description |
|---|---|---|
| 1 | Common Anode | Shared positive terminal for all three LEDs |
| 2 | Red Cathode | Negative terminal for the red LED |
| 3 | Green Cathode | Negative terminal for the green LED |
| 4 | Blue Cathode | Negative terminal for the blue LED |
Below is an example of how to connect and control the 5 mm RGB LED using an Arduino UNO.
// Define pins for the RGB LED
const int redPin = 9; // Red cathode connected to pin 9
const int greenPin = 10; // Green cathode connected to pin 10
const int bluePin = 11; // Blue cathode connected to pin 11
void setup() {
// Set RGB pins as outputs
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Example: Cycle through red, green, and blue 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 LED color
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, 255 - redValue); // Invert value for common anode
analogWrite(greenPin, 255 - greenValue); // Invert value for common anode
analogWrite(bluePin, 255 - blueValue); // Invert value for common anode
}
LED Not Lighting Up:
Incorrect Colors or No Color Mixing:
LED Flickering:
By following this documentation, you can effectively use the 5 mm RGB LED, Common Anode, in your projects and achieve vibrant, customizable lighting effects.