// Declare pin 13 as a button
int buttonPin = 13;
int ledPins[] = {2, 3, 4, 5, 6, 7, 8}; // Array of pins for LEDs
int delayTime = 10;
int buttonState;
int delayEnd = 300;

// Setup function
void setup() {
 // Set all LED pins to output
 for (int i = 0; i < 7; i++) {
   pinMode(ledPins[i], OUTPUT);
 }
 // Set button pin to input
 pinMode(buttonPin, INPUT);
}


// Loop function
void loop() {
  // Read the state of the button
  buttonState = digitalRead(buttonPin);
  // If the button is pressed, generate a random number
  if (buttonState == HIGH) {
    for (int i = 0; i < 9; i++) {
      // Loop through each LED
      for (int j = 0; j < 7; j++) {
        // Turn on the LED
        digitalWrite(ledPins[j], HIGH);
        // Delay
        delay(delayTime);
        // Turn off the LED
        digitalWrite(ledPins[j], LOW);
      }
      // Increase the delay time
      delayTime += 30;
    }
    // Reset the delay time
    delayTime = 5;

    int randomNumber = random(1, 7);
    // Call the function corresponding to the random number
    switch (randomNumber) {
      case 1:
        function1();
        break;
      case 2:
       function2();
       break;
      case 3:
       function3();
       break;
     case 4:
       function4();
       break;
     case 5:
       function5();
       break;
       case 6:
       function6();
       break;
     case 7:
       function7();
       break;
    }
  }
}

// Function 1
void function1() {
  for (int i = 0; i < 7; i++) {
     
       digitalWrite(ledPins[i], HIGH);
       delay(delayEnd);
       digitalWrite(ledPins[i], LOW);
       
   }
   digitalWrite(ledPins[6], HIGH);
}
// Function 2
void function2() {
  for (int i = 0; i < 6; i++) {
     
       digitalWrite(ledPins[i], HIGH);
       delay(delayEnd);
       digitalWrite(ledPins[i], LOW);
      }
    digitalWrite(ledPins[5], HIGH);
}
// Function 3
void function3() {
  for (int i = 0; i < 5; i++) {
     
       digitalWrite(ledPins[i], HIGH);
       delay(delayEnd);
       digitalWrite(ledPins[i], LOW);
   
   }
   digitalWrite(ledPins[4], HIGH);
}
// Function 4
void function4() {
  for (int i = 0; i < 4; i++) {
     
       digitalWrite(ledPins[i], HIGH);
       delay(delayEnd);
       digitalWrite(ledPins[i], LOW);
   
   }
   digitalWrite(ledPins[3], HIGH);
}
// Function 5
void function5() {
  for (int i = 0; i < 3; i++) {
     
       digitalWrite(ledPins[i], HIGH);
       delay(delayEnd);
       digitalWrite(ledPins[i], LOW);
     
   }
   digitalWrite(ledPins[2], HIGH);
}
// Function 6
void function6() {
  for (int i = 0; i < 2; i++) {
     
       digitalWrite(ledPins[i], HIGH);
       delay(delayEnd);
       digitalWrite(ledPins[i], LOW);
     }
    digitalWrite(ledPins[1], HIGH);
}
// Function 7
void function7() {
  for (int i = 0; i < 1; i++) {
     
       digitalWrite(ledPins[i], HIGH);
       delay(delayEnd);
       digitalWrite(ledPins[i], LOW);
     }
     digitalWrite(ledPins[0], HIGH);   
}
$abcdeabcde151015202530fghijfghij