turn on and off 4 LEDS with push button

Hello,
I am begginer and I am tryign to do this. please help me...

Each time the button is pressed, the four LEDs are turned on in turn, -> I did it,
and then, I want to turn off 4 LEDs in turn, each time I press the button.
I searched various tutorials on the web, but all about 1 LED or no push button.
Thanks,

int ledPins[] = {7, 9, 11, 13};
int buttonPin = 2;
int preButton;
int buttonState;
int whichLedPin;

void setup() {
int index;
for (index = 0 ; index <= 3 ; index++) {
pinMode(ledPins[index], OUTPUT);
}
pinMode(buttonPin, INPUT);
}

void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && preButton == LOW) {
whichLedPin++;
if (whichLedPin > 3) {
whichLedPin = 0;
}
delay(50);
}
preButton = buttonState;

for (int i = 0; i < 4; i++) {
if (whichLedPin == i) {
digitalWrite(ledPins*, HIGH);*

  • } *

  • for (int i = 0; i > 4; i--) {*

  • if (whichLedPin == i) {*
    _ digitalWrite(ledPins*, LOW);_
    _
    } _
    _
    }_
    _
    }*_

uint8_t arrayLEDPins[] = {2, 3, 4, 5}, nCurrentLED = 0, nButtonPin = 2;
volatile bool bButtonPressed = false;

void buttonISR()
{
    noInterrupts();
    bButtonPressed  = true;
}


void setup()
{
    attachInterrupt(digitalPinToInterrupt(nButtonPin ), buttonISR, RISING);
    for (uint8_t nI = 0; nI < sizeof arrayLEDPins; nI++)
        pinMode(arrayLEDPins[nI], OUTPUT);
    
}

void loop()
{
    if (bButtonPressed)
    {
        if (nCurrentLED == sizeof arrayLEDPins)
        {
            for (uint8_t nI = 0; nI < sizeof arrayLEDPins; nI++)
                digitalWrite(arrayLEDPins[nI], LOW);
            nCurrentLED = 0;
        }
        else
            digitalWrite(arrayLEDPins[nCurrentLED++], HIGH);
     
        bButtonPressed = false;
        interrupts();
    }
}
void buttonISR()
{
    noInterrupts();
    bButtonPressed  = true;
}

Interrupts are disabled when an ISR is running. Turning them off again is pointless.

They are turned back on when the ISR ends.

Since loop() is non-blocking, using interrupts to read a switch state is overkill.