// Pin definitions for RGB LED
const int redPin = 12; // GPIO pin for the red channel
const int greenPin = 13; // GPIO pin for the green channel
const int bluePin = 14; // GPIO pin for the blue channel
void setup() {
// Initialize RGB LED pins as OUTPUT
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Turn on the red LED
setColor(255, 0, 0); // Red
delay(1000); // Delay for 1 second
// Turn on the green LED
setColor(0, 255, 0); // Green
delay(1000); // Delay for 1 second
// Turn on the blue LED
setColor(0, 0, 255); // Blue
delay(1000); // Delay for 1 second
// Turn off the RGB LED
setColor(0, 0, 0); // Off
delay(1000); // Delay for 1 second
}
// Function to set the RGB LED color
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
}