/*
This code initializes an RGB LED module and displays the primary colors of red, green, and blue.
It then proceeds to display the seven colors of the rainbow in sequence.
Board: ESP32 Development Board
Component: RGB LED module
*/
// Pin numbers for each color channel
const int rledPin = 6; // pin connected to the red color channel
const int gledPin = 5; // pin connected to the green color channel
const int bledPin = 4; // pin connected to the blue color channel
void setup() {
pinMode(rledPin, OUTPUT);
pinMode(gledPin, OUTPUT);
pinMode(bledPin, OUTPUT);
}
void loop() {
setColor(255, 0, 0); // Set RGB LED color to red
delay(1000);
}
void setColor(int R, int G, int B) {
analogWrite(rledPin, R); // Set the intensity of the red color channel
analogWrite(gledPin, G); // Set the intensity of the green color channel
analogWrite(bledPin, B); // Set the intensity of the blue color channel
}