The minimum wiring for a switch is to connect the switch between the microcontroller pin and ground, then in the sketch, turn on the internal pullup resistor. This will cause the pin to be HIGH when the switch is open (or if it's a normally open button switch, when the button is not pushed), and LOW when the switch is closed (button pushed). That might be backwards from the obvious way to think about it, but it saves the external resistor. For two or more, just connect each switch between a pin and ground.

so I could've done the same for the push button too? why do they show the inferior resistor schematic if it is possible to to it without the resistor?

Who knows. First there is no 'they', most tutorials and guides are the result of one persons effort. Perhaps he/she was trying to build up the users knowledge of basic electronics and the components one uses to built circuits, and using a hidden, software enabled, pull-up resistor was not what the author though was a better way to teach such concepts as pull-ups and pull-downs. One should understand both methods and when one method is better then the other. Note there is no software pull-down option, so learning about how they work is a useful lesson.

But yes, when interfacing to simple passive switch contacts, using the internal pull-ups is the better method.

One can only guess to answer that question, as you don't tell us who has told you to do so.One reason was already given:If you or someone else has trouble with the fact that a non pressed button will result in a HIGH and a pressed button will result in a LOW, this is a hardware way to solve that.Ofcourse you'd have to consider cost of the resistor (a few cents to buy it, some more to integrate it in your design and (relatively) a lot more space on your board) to that of programming in such way that you (so you, the Arduino doesn't give a rats *ss) will keep track of the status of that button / switch.

You are right that this should be added to that thread and the code should be offered as an alternative.So the text in it is OK, because it is correctly explaining what is happening (and why) and also what happens if you change the pulldown to a pullup.It just doesn't tell you about internal pullup and the advantages to it.I think (so i'm not sure) you can do that yourself, or else request this to be done while offering the text, pictures and sketch to get it done.

Do you realize that this page and the sketch was aready created 8 years ago ?

And neither one talks about the disadvantages of the weak pull-up in a noisy environment which is why the first method with the external resistor is preferred... It Always works because the pull-up is tailored to the noise and environment. Although usually with a small bypass cap and a bead if really noisy. And that is about 99% of the knowledge on the subject. The only un-broached subject here is ESD protection for the pin and yes I Have killed processors with a poor quality keypad and extreme ESD generated by sliding across a car seat and touching the keypad. So If you are real concerned use 1N4148 diodes from the input pin to Vcc and to ground and a 10 K resistor to the processor input itself. I would.

Bob

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

If you have long wires between the switch or pushbutton and the Arduino, use an external pullup resistor, or at least make provision for one when designing a PCB. If they are close to each other, use the internal pullup resistor - that's what it's there for.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Btw. are the internal pullups, once activated by "pinMode(x, INPUT_PULLUP);" reseted after uploading a new sketch? I know auto-deactivating is now (IDE >= 1.0.1) done by explicitly setting the pin in the same sketch to output (see last paragraph http://www.adafruit.com/blog/2012/05/25/arduino-ide-1-0-1-new-features/). But what is happening after uploading a new sketch? I assume they are deactivated but I'm not a deep Atmel guy so I will not count on Guessing. :-)