How to break while infinite loop using 2nd button or 3rd button and start another LED behaviour

void loop() {
  //BLINKING LIGHTS
  buttonState = digitalRead(buttonPin);
  if (buttonState != lastButtonState) {
    if (buttonState == LOW) {

      while (true) { // your code will NEVER NEVER NEVER exit this loop
        for (int i = 0; i < 8; i++) {
          digitalWrite(ledPin[i], HIGH);
        }
        delay(d);
        for (int i = 0; i < 8; i++) {
          digitalWrite(ledPin[i], LOW);
        }
        delay(d);
      } // <== this is the closing curly brace of your NEVER-ending while(true)-loop

in addition:
Are you ready to learn a

very different way

of coding?

it is very different because this different way of coding uses

  • zero times function delay()
  • zero times for-loops
  • zero times while-loops

all looping is done by

void loop()

.
.
I'm sure this creates a big

?

inside your head.
Huh ? What? How should I ever code .... ???

If you want a functionality like you have describes above. There are two ways:

Way 1:
don't learn anything new and have to write a lot of code for it.
which means adding a lot of things to each and every single for-loop and each and every single while-loop

Way 2:
learn something new

only once

and then write much shorter code

which way do you prefer?

best regards Stefan