Hi guys in this instructables we will learn how to use RGB LED with Arduino and make the LED glow in different colors.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Things You Need
Step 2: Basics of RGB LED
The RGB LED will have four pins as shown in figure.
PIN1: Color 1 negative terminal in common anode or color 1 positive terminal in common cathode
PIN2: Common positive for all three colors in Common anode type or common negative for all three colors in common cathode type RGB LED.
PIN3: Color 2 negative terminal or color 2 positive terminal
PIN4: Color 3 negative terminal or color 3 positive terminal
So there are two types of RGB LEDs, one is common cathode type (common negative) and other is common anode type (common positive) type. In CC (Common Cathode or Common Negative), there will be three positive terminals each terminal representing a color and one negative terminal representing all three colors. The internal circuit of a CC RGB LED can be represented as below.
Common Cathode RGB LED
In Common Cathode type, If we want RED to be On in above, we need to power the RED LED pin and ground the common negative. The same goes for all the LEDs. In CA (Common Anode or Common Positive), there will be three negative terminals each terminal representing a color and one positive terminal representing all three colors.
The internal circuit of a CA RGB LED can be represented as shown in figure.
Common Anode RGB LED
In Common Anode type, if we want RED to be on in above, we need to ground the RED LED pin and power the common positive. The same goes for all the LEDs.
In our circuit we are going to use CA (Common Anode or Common Positive) type. If you want to connect more RGB LEDs, say 5, then you need 5x4= 20 PINS usually, but we can reduce this PIN usage to 8 by connecting RGB LEDs in parallel and by using a technique called multiplexing.
Step 3: Circuit Diagram
Follow the circuit diagram shown in the image and connect everything According to the schmatics.
Step 4: Coding Part
A RGB LED is a combination of three different LEDs RED LED, GREEN LED & BLUE LED. so if you want any color you can mix up few percentage of red green and blue color to get uo & for that we will use analogWrite to use whatever the value of each color you want.
So copy the following code & Upload it to arduino :
pinMode(9,1); //red led
pinMode(10,1); //green led
pinMode(11,1); //blue led
//Setting 9 to 255 will make it glow red color
//Setting red,green & blue to 255 will light up as white
//Setting red & blue to 255 will make it glow purple
Step 5: LED Output
So finally i Uploaded my code to arduino board and RGB LED is working as we expected.
1 Person Made This Project!
Yeobiu1203 made it!