I have wired a PIR sensor to control a LED light. When plugging in the circuit, the LED lights automatically and the PIR sensor does not control it at all. The PIR sensor model is: hc-sr501. The code I was using goes as follows,
""No external resistor is necessary to limit current to the LED, because pin 13 already has built-in resistance to limit current flow."
Not true. Pin13 of an Uno R3 is just like any other pin. You could damage the Arduino by not using a current limiting resistor."
This comment basically sais that you always have to use a current limiting resistor with a LED, even on pin13.
Otherwise you run the risk of blowing that Arduino pin.
"The article forgot to mention that the PIR sensor pictured already has a build-in timer, that could be factory-set to several minutes.
If you want the Arduino to be in control of timing, and not the PIR, then you must first set the timer of the PIR to minimum.
This can be done by turning the 'time' control pot on the PIR fully anticlockwise."
This comment explains that you have to turn the 'time' pot fully anticlockwise (and leave it there) if you want the Arduino to be in control.
The default setting (in the middle) is a ~3minute 'on' time of the PIR itself.
Note that the PIR (and your code) will re-trigger on the slightest movement in a radius of 7meters.
That includes moving air with a temp difference (hot radiator, open window).
Leo..
Thank you very much! We have added a resistor since we started but have noticed no difference. In regards to turning the factory default time to minimum, we have been playing around with that and still experiencing no difference. I appreciate the advise though, have a nice day
rydog:
In regards to turning the factory default time to minimum, we have been playing around with that and still experiencing no difference.
You shouldn't be playing with that pot.
As said, turn it fully anticlockwise and leave it there.
That sets the PIR itself to the minimum 'on' time, so the Arduino can be in control if the timing.
Leave the 'sensitivity' pot in the middle. It does not adjust sensitivity/range.
Your code should work, although "delay(60000);" is "beginner's code".
The Arduino does nothing (freezes) for 60 minutes seconds.
Better to manage long delay times like this with millis().
Look at the "BlinkWithoutDelay" sketch in the examples of the IDE.
Try changing the Arduino delay from 60000 to 5000.
So you won't have to wait that so during testing.
Leo..