0% found this document useful (0 votes)
4 views

Write the Arduino code and implement the program to blink an RGB LED using Arduino board

The document provides Arduino code to blink an RGB LED using an Arduino board. It defines the pins for red, green, and blue LEDs, sets them as outputs in the setup function, and then cycles through each color with a 1-second delay in the loop function. The code ensures that only one color is on at a time while the others are off.

Uploaded by

shihankv807
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Write the Arduino code and implement the program to blink an RGB LED using Arduino board

The document provides Arduino code to blink an RGB LED using an Arduino board. It defines the pins for red, green, and blue LEDs, sets them as outputs in the setup function, and then cycles through each color with a 1-second delay in the loop function. The code ensures that only one color is on at a time while the others are off.

Uploaded by

shihankv807
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Write the Arduino code and implement the program to blink an RGB LED

using Arduino board .

Arduino Code
// Define RGB LED pins

#define RED_PIN 10 // Red pin connected to digital pin 10

#define GREEN_PIN 9 // Green pin connected to digital pin 9

#define BLUE_PIN 8 // Blue pin connected to digital pin 8

void setup() {

// Set RGB LED pins as outputs

pinMode(RED_PIN, OUTPUT);

pinMode(GREEN_PIN, OUTPUT);

pinMode(BLUE_PIN, OUTPUT);

void loop() {

// Turn on the red LED, turn off the green and blue LEDs

digitalWrite(RED_PIN, HIGH);

digitalWrite(GREEN_PIN, LOW);

digitalWrite(BLUE_PIN, LOW);

delay(1000); // Delay for 1 second


// Turn on the green LED, turn off the red and blue LEDs

digitalWrite(RED_PIN, LOW);

digitalWrite(GREEN_PIN, HIGH);

digitalWrite(BLUE_PIN, LOW);

delay(1000); // Delay for 1 second

// Turn on the blue LED, turn off the red and green LEDs

digitalWrite(RED_PIN, LOW);

digitalWrite(GREEN_PIN, LOW);

digitalWrite(BLUE_PIN, HIGH);

delay(1000); // Delay for 1 second

You might also like