hey , first Thanks reading.
i have 3 of the Motion sensor (HC-SR501) , but they dosent work ! all the time the sensor return HIGH , also when ther is no motion .
i try many options but nothing!!!
i lost of mind ..
adding the code and the connections:
int pirPin = 4;
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
}
void loop(){
int pirVal = digitalRead(pirPin);
Serial.println(pirVal);
}
and video but its in Hebrew so sorry .. in the video we can see :
the sensor in front empty room - no motion, but the sensor return 1 (HIGH). (yes wait 30 sec before , yes I checked the Potentiometer ).
I see you have adjusted the "time" pot to maximum.
That is a delay of about 7 minutes before the sensor output goes LOW.
Adjust the "time" pot fully anti-clockwise, and leave it there.
Time delays can/should be done in software.
Fully anti-clockwise is an "ON" time of about 3 seconds.
The sensitivety pot should be in the middle.
It it NOT a distance/sensitivity control.
Leave it in the middle.
Leo..
2trillion:
You should intialize pirVal before the loop.
Why? It's not even declared outside the 'loop()' function, so how can it be initialised earlier?
If you mean it should be declared outside the 'loop()', as a 'global', once again - why?
In my experience, I had to include a low pass filter before the input to the board.
In my experience with the same PIR detector, this is not at all necessary. I've had a pair of these running for over a year without a single problem that would require a low-pass filter between the PIR detector output and the micro pin. (In fact, there have been no problems whatsoever.)