const int btnBlue = 11;
const int btnGreen = 12;
const int ledBlue = 3;
const int ledGreen = 2;
int prevBtnBlueState = LOW;
void setup() {
pinMode(btnBlue, INPUT);
pinMode(btnGreen, INPUT);
pinMode(ledBlue, OUTPUT);
pinMode(ledGreen, OUTPUT);
}
void loop() {
handleButtonToggle(btnBlue, ledBlue);
handleButtonState(btnGreen, ledGreen);
}
void handleButtonToggle(int buttonPin, int ledPin) {
int buttonState = digitalRead(buttonPin);
if (buttonState == LOW && prevBtnBlueState == HIGH) {
digitalWrite(ledPin, !digitalRead(ledPin));
}
prevBtnBlueState = buttonState;
}
void handleButtonState(int buttonPin, int ledPin) {
int buttonState = digitalRead(buttonPin);
digitalWrite(ledPin, buttonState == HIGH);
}