So I have been working with the Leonardo on a project for several months now using two passive infrared motion sensors (one analog and one digital). My problem is with the digital pins. The code below shows a basic motion detection sketch, the code itself I believe is correct but I could be missing something.
So even if I use digitalWrite() and drive the pin LOW, my multimeter still shows 2.5V on the pin. The sensor itself is not the issue as it work perfectly and goes to 5V or HIGH when motion is detected. Problem is the arduino's cutoff voltage for HIGH and LOW is around 2.5V so my code is really confused. I have gone through and checked the pins for short circuiting just in case something happened even though I believe nothing has.
Is there something I am missing? I am using digital pins that don't affect my SD shield or LCD at all so I am wondering why digitalWrite() won't drive the pin LOW or HIGH, or why my digital input isn't picking up my sensors output.
Any help or suggestions are greatly appreciated.
Here is the datasheet for the sensor just in case anyone wants it. We are using spot detection digital sensors.
A: digitalWrite() to a pin set to INPUT does not set the pin LOW.
B: According ot the datasheet,
Output voltage (When detecting) : Vdd-0.5V Open when not detecting
I don't see your schematic, so I can only make an assumption that you do not have a pull-down resistor on the digital pin, and if that pin is open, it will float, and likely show HIGH on a digitalRead().
Ah, I see the problem with the sensor being open when not detecting. Here is my code as well.
I am going to try the pulldown resistor again tomorrow in the lab. I made a crude attempt at a schematic for it, if I get your meaning for the pulldown resistor.
niema045:
Ah, I see the problem with the sensor being open when not detecting. Here is my code as well.
I am going to try the pulldown resistor again tomorrow in the lab. I made a crude attempt at a schematic for it, if I get your meaning for the pulldown resistor.
Not quite. The pulldown resistor goes from output to GND. That way, when the sensor is not detecting, the output goes to OPEN and the pull-down resistor ensures that the pin 'sees' GND. Make it about 10K. Low enough to pull the pin down, and high enough to draw very little current when the sensor is detecting.