#define RED_PIN 25
#define GREEN_PIN 26
#define BLUE_PIN 27
#define BTN_RED 14
#define BTN_GREEN 12
#define BTN_BLUE 13
#define PWM_FREQ 5000
#define PWM_RES 8 // 0-255
void setup() {
// Butonlar
pinMode(BTN_RED, INPUT_PULLUP);
pinMode(BTN_GREEN, INPUT_PULLUP);
pinMode(BTN_BLUE, INPUT_PULLUP);
ledcAttach(RED_PIN, PWM_FREQ, PWM_RES);
ledcAttach(GREEN_PIN, PWM_FREQ, PWM_RES);
ledcAttach(BLUE_PIN, PWM_FREQ, PWM_RES);
}
void setColor(int r, int g, int b) {
ledcWrite(RED_PIN, r);
ledcWrite(GREEN_PIN, g);
ledcWrite(BLUE_PIN, b);
}
void loop() {
if (!digitalRead(BTN_RED)) {
setColor(255, 0, 0);
}
else if (!digitalRead(BTN_GREEN)) {
setColor(0, 255, 0);
}
else if (!digitalRead(BTN_BLUE)) {
setColor(0, 0, 255);
}
}