#define R_BTN_PIN 33
#define G_BTN_PIN 34
#define B_BTN_PIN 35
#define R_COLOR_PIN 14
#define G_COLOR_PIN 13
#define B_COLOR_PIN 12
int r = 0;
int g = 0;
int b = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(R_BTN_PIN, INPUT_PULLUP);
pinMode(G_BTN_PIN, INPUT_PULLUP);
pinMode(B_BTN_PIN, INPUT_PULLUP);
pinMode(R_COLOR_PIN, OUTPUT);
pinMode(G_COLOR_PIN, OUTPUT);
pinMode(B_COLOR_PIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(R_BTN_PIN) == LOW)
{
r++;
if (r > 255) r = 0;
}
if (digitalRead(G_BTN_PIN) == LOW)
{
g++;
if (g > 255) g = 0;
}
if (digitalRead(B_BTN_PIN) == LOW)
{
b++;
if (b > 255) b = 0;
}
analogWrite(R_COLOR_PIN, r);
analogWrite(G_COLOR_PIN, g);
analogWrite(B_COLOR_PIN, b);
delay(10); // this speeds up the simulation
}