#define LED1_PIN 4
#define LED2_PIN 5
#define LED3_PIN 6
#define LED4_PIN 7
#define BTN_PIN 8
#define DELAY_TIME 250

int leds[] = {LED1_PIN, LED2_PIN, LED3_PIN, LED4_PIN};
const byte NUM_LEDS = sizeof(leds) / sizeof(leds[0]);

void setup() {
  Serial.begin(9600);
  pinMode(BTN_PIN, INPUT_PULLUP);
  for (byte i = 0; i<NUM_LEDS; i++) {
    pinMode(leds[i], OUTPUT);
  }
}
void loop() {
  static byte lastLED = 4;
  static byte nextLED = 0;

  bool buttonState = digitalRead(BTN_PIN);
  
  if (!buttonState){
    digitalWrite(leds[lastLED], LOW);
    delay(DELAY_TIME);
    digitalWrite(leds[nextLED], HIGH);
    delay(DELAY_TIME);
    lastLED = nextLED;
    ++nextLED %= 4;
  }
  else {
    for (byte i = 0; i < NUM_LEDS; i++) {
      digitalWrite(leds[i], LOW);
      lastLED = 4;
      nextLED = 0;
    }
  }
}