#define red_pin 27
#define green_pin 26
#define BUZZER 14
void setup() {
// Configure LED PWM functionalities.
ledcSetup(0, 5000, 8);
ledcSetup(1, 5000, 8);
// Attach RGB pins.
ledcAttachPin(red_pin, 0);
ledcAttachPin(green_pin, 1);
// Configure BUZZER functionalities.
ledcSetup(2, 100, 12); // Set initial frequency to 100 Hz
// Attach BUZZER pin.
ledcAttachPin(BUZZER, 2);
Serial.begin(115200);
}
void loop() {
changeColor(255, 255);
// Change buzzer frequency to different values with a 0.5-second interval
ledcWriteTone(2, 100); // Change buzzer frequency to 100 Hz
delay(500);
ledcWriteTone(2, 1500); // Change buzzer frequency to 1.5 kHz
delay(500);
ledcWriteTone(2, 2200); // Change buzzer frequency to 2.2 kHz
delay(500);
}
void changeColor(int R, int G) {
// Display color pattern on the module.
ledcWrite(1, 255 - R);
ledcWrite(1, 255 - G);
// Define the rgb color variable and print it on the serial monitor.
String color = "rgb(" + String(R) + "," + String(G) + ",0)";
Serial.print("Color: " + color);
}