//lights sounds aurostart wokwi ligyts sounds no toggle
int leds[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; // array to store the LED pins
int numLeds = 10; // number of LEDs in the array
unsigned long lastTime = 0; // variable to store the last time the LEDs were updated
unsigned long interval = 200; // interval for updating the LEDs (in milliseconds)
int sound = 13;
void setup() {
// initialize the LED pins as outputs
for (int i = 0; i < numLeds; i++) {
pinMode(leds[i], OUTPUT);
}
// set the switch pin as input without internal pull-up resistor
pinMode(sound, OUTPUT);
randomSeed(analogRead(A7));
digitalWrite(2, HIGH);
}
void loop() {
// check if it's time to update the LEDs
if (millis() - lastTime >= interval) {
// randomize the sequence of the LED pins
for (int i = 0; i < numLeds; i++) {
int j = random(i, numLeds);
if (i != j) {
int temp = leds[i];
leds[i] = leds[j];
leds[j] = temp;
}
// turn on the LEDs in the randomized sequence
for (int i = 0; i < numLeds; i++) {
digitalWrite(leds[i], HIGH);
delay(random(2000, 4001)); // Random delay between 2 to 4 seconds
}
// wait
delay(10000);
digitalWrite(sound, HIGH);
delay(10000);
digitalWrite(sound, LOW);
delay(5000);
// turn off the LEDs in a random sequence
for (int i = 0; i < numLeds; i++) {
int j = random(i, numLeds);
int temp = leds[i];
leds[i] = leds[j];
leds[j] = temp;
digitalWrite(leds[i], LOW);
delay(random(1000, 3001)); // Random delay between 2 to 4 seconds
}
// reset the last update time
lastTime = millis();
delay(10000);
}
} else {
// turn off all the LEDs if the switch is not pressed
for (int i = 0; i < numLeds; i++) {
digitalWrite(leds[i], LOW);
}
}
}