const int buttonPin = 15;
const int ledCount = 3;
int ledPins[] = {5, 18, 19};
int currentLed = 0;
bool buttonState = false;
bool lastButtonState = false;
void setup() {
Serial.begin(115200);
pinMode(buttonPin, INPUT);
for (int i = 0; i < ledCount; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && lastButtonState == LOW) {
digitalWrite(ledPins[currentLed], LOW);
currentLed = (currentLed + 1) % ledCount;
digitalWrite(ledPins[currentLed], HIGH);
delay(200);
}
lastButtonState = buttonState;
}