Scan the QR to open the code. Copy the code and paste it in your Arduino IDE.
Once you paste the code in Arduino IDE, Compile the code and upload it in the Arduino Nano.
Code:
int RED=11; //Red pin of RGB led is connected to digital pin 11
int GREEN=12; //Green pin of RGB led is connected to digital pin 12
int BLUE=13; //Blue pin of RGB led is connected to digital pin 13
void setup() {
pinMode(RED,OUTPUT);
pinMode(GREEN,OUTPUT); //Set all the pins of RGB as OUTPUT
pinMode(BLUE,OUTPUT);
}
void loop() {
digitalWrite(RED,HIGH);
digitalWrite(GREEN,LOW); //RED color
digitalWrite(BLUE,LOW);
delay(2000);
digitalWrite(RED,LOW);
digitalWrite(GREEN,HIGH); //GREEN color
digitalWrite(BLUE,LOW);
delay(2000);
digitalWrite(RED,LOW);
digitalWrite(GREEN,LOW); //BLUE color
digitalWrite(BLUE,HIGH);
delay(2000);
digitalWrite(RED,HIGH);
digitalWrite(GREEN,HIGH); //YELLOW color
digitalWrite(BLUE,LOW);
delay(2000);
digitalWrite(RED,HIGH);
digitalWrite(GREEN,LOW); //MAGENTA color
digitalWrite(BLUE,HIGH);
delay(2000);
digitalWrite(RED,LOW);
digitalWrite(GREEN,HIGH); //CYAN color
digitalWrite(BLUE,HIGH);
delay(2000);
digitalWrite(RED,HIGH);
digitalWrite(GREEN,HIGH); //WHITE color
digitalWrite(BLUE,HIGH);
delay(2000);
}
Output:
Once the code is uploaded, we can see on the board that the RGB LED glows in different colors like Red, Green, Blue, Cyan and many more.
Login
Accessing this course requires a login. Please enter your credentials below!