Hello.
For my first Arduino projects I want to have LEDs lit on my stairs when motion is detected.
I attached 2 PIR HC-SR501 sensors to my arduino. But no motion is detected, value is always LOW/0.
I tried 3 different sensors, all detect no motion.
I cheked the voltage, it is 4,9V.
I tried turning the pots in different positions.
All without result. Can they be all broken or is it my code?
int timer = 200;
int timerUit = 5000;
const int pirBeneden = 2;
const int pirBoven = 3;
int pirStatusBeneden = LOW;
int pirStatusBoven = LOW;
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
If having doubts about your sensor, you can measure voltage of output pin. It should switch between 3.3V and 0V from motion.
Also, use some simple demo-code to start with...
Even when using a number of pins with contiguous numbering I find it just as easy to put the pin numbers in an array and iterate through that to set their pinMode()s and it avoids problems such as yours