Supply 5v from arduino and ground. The middle pin connected to D10 as a digital input. I can then read this in a loop and all is fine and works perfectly.
Then I add an LED & resistor to pin D3 as an output. When the motion sensor goes high I write high to the LED output and the LED comes on as expected.
The problem I am seeing is that when the sensor indicates low for no motion and this is detected in the arduno, then low is written to the LED output pin. For some reason the sensor immediately signals on again (even if there is no motion). Then we go around in a loop on/off etc.
Any idea on why simply turning on the LED is confusing the sensor and what I could change to stop it?
It might be noice. I had a similar problem using this sensor together with a 4 digit led display. When the led brightness was low, it did have a few detentions when it was nothing moving. When I increased the brightness it detected movement all the time.
I solved it by adding a LC filter on the power line to the sensor, like this:
Thanks. Looks like I need to order a few bits (I am still a beginner at this). C2 is a non-polarised capacitor? and L1 is an inductor? I have some electrolytic capacitors that will do for c1 and c3.
Its the lack of decoupling. The large current spike as the LEDs turn on will knock the voltage down very
briefly (we're talking 0.0000001 of a second timescales), and confuse the sensor. It
simply needs more decoupling capacitance on it - right next to it, preferrably a 100nF ceramic cap and 10uF
of electrolytic. These hold the voltage from dropping by providing the current until the power supply and wiring
catches up
The inductance of the power wiring between sensor and LED module is probably enough at these
timescales.