INPUT_PULLUP usage

I was just reading about the new INPUT_PULLUP in Arduino 1.0.1+ and had a couple of questions.
Firstly my understanding of this function is that instead of:
10k resistor from 'button' pin to ground and then 5v > 'button' pin being toggled by the button/switch etc.
if (buttonpin == HIGH) {
do stuff here
}

We can use:
Only GND > 'button' pin via switch/toggle
INPUT_PULLUP instead of INPUT
if (buttonpin == LOW) {
do stuff here
}

So firstly is my understanding correct?
Secondly, is there a limit on how many INPUT_PULLUP's we can use or is it available to every digital pin?
Thirdly, are there any con's in using it this way? To me saving on a resistor and the additional wiring is a massive pro, but why would one NOT use this INPUT_PULLUP and instead use INPUT with a manually inserted pulldown resistor?

The pull-up isn't new. It was just more cryptic to use before 1.0.1. Every pin has a pull-up resistor that can be turned on, including the analog inputs.

One tradeoff is that Pull-Ups will have inverted logic relative to a Pull-Down. E.g. when a button is NOT pressed, the value will be HIGH. when the button IS pressed, the value will be LOW. (This trips up some people at first.)

So firstly is my understanding correct?
Secondly, is there a limit on how many INPUT_PULLUP's we can use or is it available to every digital pin?
Thirdly, are there any con's in using it this way? To me saving on a resistor and the additional wiring is a massive pro, but why would one NOT use this INPUT_PULLUP and instead use INPUT with a manually inserted pulldown resistor?

1 Yes.
2 No limits.
3 Resistors value are not accurate, 20 - 50 kOhm. Plus, for battery powered MCU this is too low, if button get pressed for long.

Thanks for that James - That's what I thought in terms of the logic (The new relay circuits I purchased also were LOW to trigger instead of HIGH which caused me some issues)
Can anyone elaborate on Magician's 3rd comment? More specifically:
Is there a problem with having these 'bad' valued resistors if I'm only using it to take input(s) for a button(s)?
What is meant by "Plus, for battery powered MCU this is too low, if button get pressed for long."?

If the internal pull up is only 20k, then each time a button is pressed 250uA is drawn. I guess the concern is the button is held down for a long period of time, it could contribute to reduced battery life. With external resistors you could use larger (known) values.

I'm not sure I'd put a lot of thought into that though, but, that's just me.

So in a nutshell for anyone else who looks at this thread the following is correct for using INPUT_PULLUP?:
Pro: Less physical wiring
Cons: 250ua (0.00125w) extra drain per button in use. Logic reversed - If (XX == HIGH) now needs to be If (XX == LOW) for the function to remain working the same)

For my particular project the battery life doesn't matter as it's going to have 12v 7AH batteries as it's only a small part of a larger project but I understand for some people that battery life is critical.

Thanks for the help guys, you've saved me about $0.20 in resistors and $50 in time :slight_smile:

in a noisy environment and with longish leads >6" I would install a 1K pull-up or a .047 uf cap from the button pin to Vcc, might even buy some cheap debounce w/o the 1K resistor. Both together would simply add to the noise suppression.

Doc

acecombat:
So in a nutshell for anyone else who looks at this thread the following is correct for using INPUT_PULLUP?:
Pro: Less physical wiring
Cons: 250ua (0.00125w) extra drain per button in use. Logic reversed - If (XX == HIGH) now needs to be If (XX == LOW) for the function to remain working the same)

For my particular project the battery life doesn't matter as it's going to have 12v 7AH batteries as it's only a small part of a larger project but I understand for some people that battery life is critical.

Thanks for the help guys, you've saved me about $0.20 in resistors and $50 in time :slight_smile:

The current drain is only when the switch is closed. However, you get the same draw if you use an external resistor -- it's just that you get to use whatever value resistor you want (although 10k to 20k is standard -- I've always used 10k, so the built in resistor draws less power).

The whole point was not what was conventional but a possible source of intermittent sketch operation due to noise being picked up if only the weak pull-up is used, either by passing it with more pull-up current (lowering it's input impedance to 1K instead of 20 - 50K or by by-passing the noise picked up to the positive rail and thus into the nearest big bypass with the .047uF cap a larger value might be needed the caution would be not to make it so large as to provide a delay of it's own..., either way would work. Both methods bypass the antenna lead (the wire to the button) and solve a potential noise issue that has plagued several users here. In those cases it was an open input pin, disconnected that was ultimately tied to a pin with nothing connected to it, merely proximity to the OP's hand.

Doc