Do analog inputs have internal pullups?

I have read that analog pins can be used as digital inputs although I have never used one that way. Do they have internal pullups just like the digital inputs so I can do pinMode(A0,INPUT_PULLUP)?

I don't know the answer, but have been wondering that too, so I'm posting there simply to get the responses in my Unread replies.

Before I answered yes, I checked the documentation to confirm... http://arduino.cc/en/Tutorial/AnalogInputPins

Since you didn't specify a particular board though...

Right but it doesn't say anything about INPUT_PULLUP. I assume that works as well on analog?

Yes it does. I would use

byte pin14 = 14; // or a suitable name for its intended function and pinMode(pin14, INPUT_PULLUP); // up to D19 on an Uno just for clarity.

The internal pull-ups work on A0-A5; they are fully functional digital pins as well as being analog input pins.

Some boards also have additional analog input pins A6 - A7 and I have read that these extra ones do not have the same digital I/O capability, but I haven't tested that myself.

CrossRoads: Yes it does. I would use

byte pin14 = 14; // or a suitable name for its intended function and pinMode(pin14, INPUT_PULLUP); // up to D19 on an Uno just for clarity.

What's wrong with A0,A1... etc? To me that is more obvious to which pin you are on. With pin14 you have to do the math. Easy addition I know but... Does having the "A" there make you think you are using it as an analog?

I just prefer it for consistency. Your call tho, you are the one maintaining the sketch.

analog input pins A6 - A7 and I have read that these extra ones do not have the same digital I/O capability

that's straight from the datasheet. You need a surface mount '328P board to even access those pins (they are not brought out on a DIP package), and not all surface mount boards brought the pins to an IO connector.

freakdaddy:

CrossRoads: Yes it does. I would use

byte pin14 = 14; // or a suitable name for its intended function and pinMode(pin14, INPUT_PULLUP); // up to D19 on an Uno just for clarity.

What's wrong with A0,A1... etc? To me that is more obvious to which pin you are on. With pin14 you have to do the math. Easy addition I know but... Does having the "A" there make you think you are using it as an analog?

Yes, using the A0 to Ax alias is the better method as it's more portable across the different controller chips the arduino boards can have.

Lefty

If your signal is weak then the pullup will mess up your reading. This applies to temperature sensors that are popular around here.

liudr: If your signal is weak then the pullup will mess up your reading. This applies to temperature sensors that are popular around here.

So, all you have to do is turn it off before you read, right?

Yes, you turn it off. But go right ahead and try both. You should know what you can get with and without the pullup.