fbpx
skip to content

Procedure

Multicolor Lights

Components required:

  • Knewton board – 1
  • Arduino Nano – 1
  • Arduino Nano Cable – 1
  • Power Bank-1
  • USB to DC jack-1

Circuit diagram:

We’ll be using the Onboard RGB LED.

Arduino Code:

  • 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.

Please enter your email address to receive your cart as a PDF.