Arduino RGB LED

Arduino RGB LED

In this Article we will learn about RGB LED.

Hardware Required:

1x Arduino Uno

1x RGB Led

4x Male-Male Jumpire Cables

 

Pin Layout:

RGB_led_pinout
RGB_led_pinout

Complete Video Instruction Set:

 

Code:

/*
*  How to use RGB LED with Arduino
*  Writer OR97.com
*  Instructions Link:https://www.or97.com/arduino-rgb-led-example
*/

int Red=11;
int Green=12;
int Blue=13;

void setup() {
// put your setup code here, to run once:
pinMode(Red,OUTPUT);
pinMode(Green,OUTPUT);
pinMode(Blue,OUTPUT);
}

void loop() {

//Red Color
ChangeRGBColor(255,0,0);
delay(1000);

//Green Color
ChangeRGBColor(0,255,0);
delay(1000);

//Blue Color
ChangeRGBColor(0,0,255);
delay(1000);

//Yellow Color
ChangeRGBColor(255, 255, 0);
delay(1000);

//purple Color
ChangeRGBColor(80, 0, 80);
delay(1000);
//Aqua color
ChangeRGBColor(0, 255, 255);
delay(1000);

ChangeRGBColor(255, 0, 255);
delay(1000);

//White Color
ChangeRGBColor(255, 255, 255);
delay(1000);
}

void ChangeRGBColor(int RedLevel,int GreenLevel,int BlueLevel){
analogWrite(Red,RedLevel);
analogWrite(Green,GreenLevel);
analogWrite(Blue,BlueLevel);
}