const int buttonPin = 13;
const int ledPin = 2;

int leds[] {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18};

int numLeds = sizeof(leds) / sizeof(int);

void setup() {
  for (int i = 0; i < numLeds; i++) {
    pinMode(leds[i], OUTPUT);
  }
  pinMode(buttonPin, INPUT_PULLUP);
  randomSeed(analogRead(A7));
}

void loop() {
  for (int i = 0; i < 2; i++) {
    // check if the button is pressed (LOW due to pull-up resistor)
    int buttonValue = digitalRead(buttonPin);
    if (buttonValue == LOW) {
      // Generate a random LED pattern
      //digitalWrite(ledPin, LOW);
      //allLedsOff();
      randomPattern();
      delay(50); // Debounce delay
    }
    else {
      //digitalWrite(ledPin, HIGH);
      allLedsOn();
    }
  }
}

void allLedsOn(){
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(leds[i], HIGH);
  }
}

void allLedsOff(){
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(leds[i], LOW);
  }
}

void randomPattern() { 
    for (int i = 0; i < numLeds; i++) {
      int ledState = random(2);
      digitalWrite(leds[i], ledState);
    }
    delay(200);
    allLedsOff();  
}