Go Down

Topic: using 20k pullup with analog input. (Read 867 times) previous topic - next topic


When using an analog pin as an analog input, is it possible to digitalWrite a high to it so that the analog input will have the 20K (5v) pull-up activated?

I'm using the pin to read an analog signal, but if it is unconnected, I want it to report maximum level.  (It tends to float around when unconnected. 

If it will work, then:
I'm using the 1.1v reference, will the pullup being at 5v burn anything out? Or is the 20K pullup between the 5v and the input to the ADC.

Yes, I can use an external pullup if necessary, but if I can eliminate a resistor or two, it would be nice.


I believe the pullup would screw with your analog readings. What are you measuring? If it is a fairly stable input when connected, why not just implement static detection in software?
Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali


In my case, the pullup won't mess up the analog readings. The external circuit will have no problem pulling down.  There is only an issue when the input is un-connected.  The input is stable, but when unconnected, the analog readings will fluctuate randomly (I believe this randomness is even noted in the Arduino documentation).

I'd rather not have to write software to check for randomness in the input values if all I have to do is set a pullup resistor.

James C4S

Apr 20, 2011, 03:55 am Last Edit: Apr 20, 2011, 03:57 am by James C4S Reason: 1
Since it is possible to switch between the AVcc reference and the 1.1V reference, it would stand to reason that applying 5V on an input while having the 1.1V reference selected is okay.  (I didn't see a note in the datasheet that warns of that particular condition.)
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com


Thanks James,
I tried it and it works fine, with 1.1v or 5v selected as reference. (The pullup is always 5v, of course.)

For anyone interested:
In my case, I just wanted to use the pullup as part of a voltage divider so I could use an on-off-on, 3-position switch, 1 resistor, and two wires to give me 3 states.  Without the internal pullup I would have had to use 2 resistors and a 3rd wire.  It's just nice to minimize things.

With a 1.1v reference, a 2.7k resistor to ground on the input will quantize to about 400. A 4.7k to ground will quantize to about 600.  With a 5v reference, a 4.7k to ground will quantize to about 125. A 20k will quantize to about 370.  This suggests there is another resistance somewhere or the ADC is taking some current.  Further experiments would be needed to find out.

Also, I noticed even when appying a very low-impedance source, which forces the input pin to stay at the same voltage, with or without the pullup, the pullup activated still causes the quantization value to raise slightly (about 10% in some cases).  So that is more evidence of another resistance and/or loading by the ADC.  Maybe this is documented, but I haven't checked.

The pullup on one analog pin does not seem to affect other analog inputs, so the isolation seems good.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131