AdamH
1
Hi guys,
I am just learning this stuff so this might sound simple to you but plz be kind,
I am trying to get a relay to activate for a sort amount of time 1 - 2 sec once a PIR sensor detects movement
then repeat every say every 5 seconds while the PIR is activated
any help with the code would be welcomed
Thank you
Have you tried it yourself ?
Do you know how to read the PIR output ?
Do you know how to test the value of the PIR output ?
AdamH
3
I can get the PIR to activate and the relay to stay on but for my purpose i only need a real short activation of the relay
like i said i am new to this wiring of the boards is easy for me coding is difficult as its all new
AdamH
6
I apologise,
Wiring the boards and there components are easy for me, Its coding that i struggle with.
Look at File->Examples->02.Digital->StateChangeDetection.
Use that to detect when the PIR changes from unactivated to activated.
When that happens: activate the relay, delay two seconds, deactivate the relay.
Repeat.
And Have a look at how millis() is used to manage timing without blocking in Several things at a time.
...R
system
10
If you need help with building a program from an empty setup/main template, start here:
Planning and Implementing an Arduino Program