I need to use Hi impedance digital inputs. I connected the input pin through a resistor divider using 100 K / 150 K. My input before the divider varies from 0 to 4.9 V. So output is expected to be between 0 & 2.95 V.
I used the following code:
Code: Select all
#define PIR_PIN 9
pinMode(PIR_PIN, INPUT);
pirState = digitalRead(PIR_PIN);
I measured with a multi-meter, and noticed that voltage on Z-Uno pin doesn't follow the divider output and seems to be constrained as if an internal pull-up were still enabled despite the "INPUT" used, and NOT "INPUT_PULLUP".
I also tried with an analog input pin 6 / ADC3, but it's the same.
A work around I found is using the analog way:
Code: Select all
int val = analogRead(A3);
if (val > 500)
pirState = HIGH;
else
pirState = LOW;
Gerard