const int numCircles = 3;
const int circlePins[numCircles][4] = {
{2, 3, 4, 5}, // First circle LEDs
{6, 7, 8, 9}, // Second circle LEDs
{10, 11, 12, 13} // Third circle LEDs
};
void setup() {
for (int i = 2; i <= 13; i++) {
pinMode(i, OUTPUT);
}
randomSeed(analogRead(0));
}
void loop() {
// Fast circular crescent pattern with increasing speed until 8 seconds
unsigned long startTime = millis();
int delayTime = 100;
while (millis() - startTime < 8000) {
for (int i = 0; i < numCircles; i++) {
int* circle = circlePins[i];
for (int j = 0; j < 4; j++) {
digitalWrite(circle[j], HIGH);
delay(delayTime); // Delay for the crescent pattern
digitalWrite(circle[j], LOW);
}
}
delayTime = max(20, delayTime - 10); // Decrease delayTime for increasing speed, but not below 20ms
}
// Randomly select a circle and blink it fast
int chosenCircle = random(0, numCircles);
int* circle = circlePins[chosenCircle];
for (int blinkCount = 0; blinkCount < 20; blinkCount++) { // Blink 20 times
for (int i = 0; i < 4; i++) {
digitalWrite(circle[i], HIGH);
}
delay(50); // Very fast delay for the rapid blinking pattern
for (int i = 0; i < 4; i++) {
digitalWrite(circle[i], LOW);
}
delay(50); // Very fast delay for the rapid blinking pattern
}
// Reset all LEDs
for (int i = 2; i <= 13; i++) {
digitalWrite(i, LOW);
}
// Delay before the next iteration
delay(random(500, 2000)); // Random delay between patterns (0.5 to 2 seconds)
}