PIR activated relays

I am very new to Arduino. I have been playing with this for a couple weeks now. I can get it to almost do what I need it to do. I have it set very simple Paralax PIR sensor. 4 relay board. Arduino uno.

Goal: Motion triggers relays on for X amount of time. Then turns off (this part I have down) Then waits X amount of time before it is triggered again. (this is my problem)

I've copied and pasted many codes off the internet and tried tinkering with them but just can't get it. The codes seem to be much more advanced for what I need it to do.

Any help is appreciated. And I'm sorry if this has been posted before. I tried to search and couldn't find much.

I have PIR sensor in input 7 and outputs 2,3,4,5 are controlling each relay.

This is for a halloween prop so when it's triggered I need it to wait a few minutes for trick or treaters to get candy and leave without it being triggered again.

I will post the code I am using when I get home tonight because I do not have the computer i use for my arduino.

The simplest way to do it would be to add a large delay after you turn the prop off. If the Arduino is supposed to be doing other things while waiting for the prop to be re-armed, delay will not do it & you'll need to use the blink without delay method instead. As the requirement is stated though, delay will get you going. Don't forget to put a UL suffix on the number of milliseconds you want to delay for.

Don't go the delay() route. Think about how YOU would deal with the situation. Each time you check the sensor, to see if there IS motion, you check to see how long it's been since the last time there was no motion. If there is motion, and it's been long enough since there was last no motion, you'd do something.

The blink without delay example shows you all about recording the last time something happened (there was no motion) and about determining what time it is now. Where it is less than adequate is explaining that it is doing something because the interval is great enough to warrant action again.

If the OP has stated his requirements accurately then I would go with delay() as suggested by wildbill. True the OP will not learn to use the BlinkWithoutDelay millis() way of timing, but why complicate things when it is not necessary ?

delay(x);does exactly what it says on the tin. It delays the code for x milliseconds. If/when the OP comes back and says that he wants to implement an override button or read a second sensor during the waiting period, then would be the time to move to a different timing mechanism.

An analogy would be to suggest using direct port manipulation to turn the relays on and off because it is 'better'. It may be smarter, faster, neater etc but it is unnecessary [u]in this case[/u].

My thought was that OP doesn't know about delay(). If he/she did, then there probably wouldn't have been a need to ask.

Learning how to delay() is one level of effort that will ultimately need to be augmented by learning how not to delay().

Learning how not to delay() is not significantly more difficult IF YOU LEARN IT FIRST. It isn't difficult later, but rewriting the code to not use delay() is. If you never fall in that trap in the first place, you never have to worry about getting out of the trap.

The easiest way to control Halloween props is to use Pico controllers from frightprops. I like Arduino, but these controllers are right out of the box easy and control mp3, motion, and video, activated just about any way imaginable