I have an Arduino Nano with two attached Motion sensors "PIXNOR HC-SR501". This sensor puts 5V on its middle Pin, when it detects motion. I have connected this Pin to my Arduino and read the value with digitalRead
Here is the simplified code of my loop:
void loop() {
motion1 = digitalRead(motion_pin1);
motion2 = digitalRead(motion_pin2);
if(motion1== HIGH) {
if(debug){
Serial.println("Motion 1");
}
}
if(motion2== HIGH) {
if(debug){
Serial.println("Motion 2");
}
}
// Wait 1,0 Second
Sleepy::loseSomeTime(1000);
}
Problem is... This used to work fine, but I had to extend the cable to the motion sensors from ~10 cm to 500 cm. Now I have the problem, that the Arduino sometimes (quite often) detects voltage on the motion pins, although there is no motion. I guess the Input-pins are is too sensitive? What can I do to prevent this flickering?