Greetings, everyone! This project delves into the fascinating world of RGB LEDs, or “Red Green Blue Light Emitting Diodes.” These unique LEDs offer a wide range of color options and can be used to create various lighting effects. Unlike traditional LEDs which only have two legs, RGB LEDs have four legs, as you can see in the illustration below. These additional legs allow for the control of each individual color, resulting in the ability to mix and match to create a vast array of hues. These versatile LEDs are commonly used in projects such as mood lighting, color-changing accents, and even in digital signage and displays. With their endless possibilities, RGB LEDs are a must-have for any maker or DIY enthusiast.
Typically, an LED has two legs: a positive leg (anode) and a negative leg (cathode). The positive leg is usually longer and is connected to the power source, while the negative leg is connected to ground.

When current flows through the LED, it causes the semiconductor material inside the device to emit light. The color of the light emitted by an LED depends on the materials used to make it.
In the case of RGB LEDs, it has 4 legs, where the additional legs are used to control the intensity of the red, green, and blue color individually, so the user can mix them to get the desired color.

Would you like to code along with me?
// Define Pins
#define BLUE 3
#define GREEN 5
#define RED 6
void setup()
{
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
}
// define variables
int redValue;
int greenValue;
int blueValue;
// main loop
void loop()
{
#define delayTime 10 // fading time between colors
redValue = 255; // choose between 1 and 255 to change color.
greenValue = 0;
blueValue = 0;
for(int i = 0; i < 255; i += 1) // fades out red bring green full when i=255
{
redValue -= 1;
greenValue += 1;
analogWrite(RED, redValue);
analogWrite(GREEN, greenValue);
delay(delayTime);
}
redValue = 0;
greenValue = 255;
blueValue = 0;
for(int i = 0; i < 255; i += 1) // fades out green bring blue full when i=255
{
greenValue -= 1;
blueValue += 1;
analogWrite(GREEN, greenValue);
analogWrite(BLUE, blueValue);
delay(delayTime);
}
redValue = 0;
greenValue = 0;
blueValue = 255;
for(int i = 0; i < 255; i += 1) // fades out blue bring red full when i=255
{
blueValue -= 1;
redValue += 1;
analogWrite(BLUE, blueValue);
analogWrite(RED, redValue);
delay(delayTime);
}
}
If you need help do not hesitate to ask, comment below or message me.























































You must be logged in to post a comment.