activate led sequencer using PIR with timer delay between LED blinks

I am trying to run a LED sequencer of 5 LEDs that will trigger with a PIR and turn on the 5 LEDs in sequence. Once it gets to the 5th LED, the program will stop and then run the sequence again when activated by the PIR. I need a standard blink from the first LED, then pause for 45 seconds before lighting the second LED. Then a 45 second pause before lighting the 3rd LED and so on. Once the 5th LED is lite and turned off, I want the program to run the sequence again when motion is detected.

I am new to programming but have been able to get the 5 LEDs to blink in sequence but in a continuous loop. I will hook the PIR to digital pin 2 if that is the best.

I would appreciate any help in figuring this out. Do I use a timer? Do I use delays? What will work?

Here is the code so far:

/* A simple program to sequentially turn on and turn off 5 LEDs created 10 October 2016 by Steve Larsen */

int LED1 = 13; int LED2 = 12; int LED3 = 11; int LED4 = 10; int LED5 = 9;

void setup() {

pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); pinMode(LED4, OUTPUT); pinMode(LED5, OUTPUT);

}

void loop() {

delay(1); //delay in between reads for stability digitalWrite(LED1, HIGH); // turn on LED1 delay(100); // wait for 100ms digitalWrite(LED2, HIGH); // turn on LED2 delay(100); // wait for 100ms digitalWrite(LED3, HIGH); // turn on LED3 delay(100); // wait for 100ms digitalWrite(LED4, HIGH); // turn on LED4 delay(100); // wait for 100ms digitalWrite(LED5, HIGH); // turn on LED5 delay(100); // wait for 100ms digitalWrite(LED1, LOW); // turn off LED1 delay(100); // wait for 100ms digitalWrite(LED2, LOW); // turn off LED2 delay(100); // wait for 100ms digitalWrite(LED3, LOW); // turn off LED3 delay(100); // wait for 100ms digitalWrite(LED4, LOW); // turn off LED4 delay(100); // wait for 100ms digitalWrite(LED5, LOW); // turn off LED5 delay(100); // wait for 100ms

}

I am new to programming but have

not been arsed to read how to post code because I am arrogant and haven't even bothered to read the how to use this forum sticky post even though it is right at the top of the list in every section of the forum.

Or at least that is how you come across at the moment.

Do you use delay? Only if you don't want anything to happen during that blink sequence.

Use an if statement to decide if you want to run that blinking.

I will look at doing the "if" to see if I can get it to work. Thanks

The advice about getting rid of the delays is good because these block everything including attempts to read you PIR device.
If you must keep the delay() statements, then you need to use an interrupt to detect the PIR which is not a technique for beginners.
Look at the standard example “blink without delay” to see how you could achieve the same pattern using millis() instead of delay().
You can divide the problem in 2 parts. Use the PIR just to light a single LED to see how it works. Then get rid of the delay statements in the second part.
If you post more code, you should use code tags as mentioned in the “sticky” which you have now been made aware of.