Playing with RGB LED's

In this tutorial, we will learn how to interface a RGB led with Arduino.
A RGB led consist of three Led’s namely red, green and blue inside a single package.

It is having three pins the longer one(2) is the GND(in the case of the common cathode) and the other three pins represent the three colors.
You all must have heard about the RGB color model, it is a model representing the colors that can be generated with the combination of three basic colors.
Now let’s interface the led and have some fun with it.
Components required
  • Resistor                         1No.              200 ohms
  • RGB led                         1No. 
  • Arduino UNO                 1No.
  • Few connecting wires
Follow the video below for circuit connection reference.
After making the circuit connections dump the code given below. 
int led1 = 3;
int led2 =5;
int led3 =6;
void setup() 

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
void loop() 

digitalWrite(led1, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led3, LOW);

The above code is to observe the basic colors; other combinations can also be generated like.

Now apply your own logic and try to generate your own patterns.
  • RGB LEDs are of two types:
                 Common anode
                 Common cathode (which we have used in the tutorial)

Join our hands-on training courses.
To know more visit us at