Halloween "eyes" in the bushes - timing issue, should be easy but I'm stuck

This program is meant to light 5 sets of LEDs off in sequence when it is dark and when someone walks by. Each set of ‘eyes’ should light up sort of quickly and in a staggered pattern - stay on for awhile and then all go off at once. Like bloop…bloop…bloop…bloop…bloop. Like it was actually a flock of birds or monsters waking up and looking at you in a cartoon.

It works - but the time between each set of ‘eyes’ turning on is too long and I can’t seem to change it at all. I put it all the way down to like 5, 8 and 15 as the initial delays and it looked just the same as when I had it set at 100. Is there some sort of limit or piece of knowledge I’m missing? Should I be using delayMicroseconds()?

Thanks!

/* I always feel like someone's watching me.
 */

#define LDR A0
#define PIR 0
#define LED1 1
#define LED2 2
#define LED3 3
#define LED4 4
#define LED5 5

int pirState;
int ldrValue;

void setup() {
  //Serial.begin(9600);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT); 
  pinMode(LED5, OUTPUT); 
  pinMode(PIR, INPUT);
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  digitalWrite(LED3, LOW);
  digitalWrite(LED4, LOW);
  digitalWrite(LED5, LOW);
}

void loop(){
  ldrValue = analogRead(LDR);
  
  pirState = digitalRead(PIR);
   
   if (pirState == HIGH) { // movement
      if (ldrValue <= 512){ // dark
        firstEyes(LED1);
        secondEyes(LED2);
        thirdEyes(LED3);
        fourthEyes(LED4);
        fifthEyes(LED5);
        allOff();
      } else { // ldrValue > 512
        allOff();
      }
    } else { 
      allOff();
    }
  // [From the original program I built this from, I decided 
  //I might not need and tried getting rid of it in case that caused the long pauses - didn't work]
  //The processing in the Arduino occurs faster
  // than the response from the PIR, and adding this delay
  // eliminated a flickering on the LED
  //delay(1000);
    }

int firstEyes(int a){
  digitalWrite(a, HIGH);
  delay(5000);
}

int secondEyes(int b){
  delay(50);
  digitalWrite(b, HIGH);
  delay(4950);
}

int thirdEyes(int c){
  delay(60);
  digitalWrite(c, HIGH);
  delay(4940);
}

int fourthEyes(int d){
  delay(100);
  digitalWrite(d, HIGH);
  delay(4900);
}

int fifthEyes(int e){
  delay(120);
  digitalWrite(e, HIGH);
  delay(4880);
}

int allOff(){
   digitalWrite(LED1, LOW);
   digitalWrite(LED2, LOW);
   digitalWrite(LED3, LOW);
   digitalWrite(LED4, LOW);
   digitalWrite(LED5, LOW);
}
int firstEyes(int a){
  digitalWrite(a, HIGH);
  delay(5000);
}

This function promises to return an int. It does not. Why not?

Why are these "eyes" supposed to come on and then wait 5 seconds, but not go off?

You are controlling the time with the delay() function. You do know something like delay(4000); will wait for 4 seconds?

Have you looked at making things random? https://www.arduino.cc/en/Reference/Random

Also, you could make a state machine to control the leds. Pick which 'state' to go to in a random fashion.

.

Depending upon your board pin 0 and A0 may be the same making it hard to both read and write the separate hardware.

Hey PaulS thanks for your questions! :)

I had seen a program where the input was initialized in the parentheses and then immediately used. Or at least that is what I thought it was doing. So the function is created so the input in the loop - firstEyes(LED1) - is initialized as 'a' and then used.

The eyes do go off- there is an all off function.

LarryD - I will definitely look into the random. I did know 1000 = a second - but it seems to be waiting about 5 seconds no matter what I do (or a least '5- one - thousands' as I count it.)

I see 4880, 4900, 4940, 4950, 5000 in the sketch. Here is your 5 seconds you are experiencing.

These are in milliseconds.

I doubt you would be able to see the difference between 4880 and 4900 this is only 20 milliseconds difference.

What would this do? delay(random(200,2000));

Do not recommend you use delay()

Edit:

define LED1 1

Stay away form D1 as it is used in serial communications. Use 2 and up.

I had seen a program where the input was initialized in the parentheses and then immediately used. Or at least that is what I thought it was doing. So the function is created so the input in the loop - firstEyes(LED1) - is initialized as 'a' and then used.

That has nothing to do with the fact that the function promises to return an int, and then does not. Either make the function return something, or change the return type so the function stops lying.