// Define the RGB LED pins
const int redPin = 15; // GPIO pin connected to the Red LED
const int greenPin = 4; // GPIO pin connected to the Green LED
const int bluePin = 2; // GPIO pin connected to the Blue LED
void setup() {
// Set the RGB LED pins as output
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Cycle through the rgb colors
showColor(255, 0, 0); // Red
delay(1000);
showColor(255, 127, 0); // Orange
delay(1000);
showColor(255, 255, 0); // Yellow
delay(1000);
showColor(0, 255, 0); // Green
delay(1000);
showColor(0, 0, 255); // Blue
delay(1000);
showColor(75, 0, 130); // Indigo
delay(1000);
showColor(148, 0, 211); // Violet
delay(1000);
}
// Function to set the RGB color
void showColor(int red, int green, int blue) {
analogWrite(redPin, red); // Set the red channel
analogWrite(greenPin, green);// Set the green channel
analogWrite(bluePin, blue); // Set the blue channel
}