Push button?

Hello! I'm an arduino noob!

I found this instructable about connecting buttons to arduino wich is different from how the arduino tutorial tells me to connect buttons.


is this true? Can I connect buttons like that without damaging my arduino? Wha'ts the difference? Why doesn't anyone do it like that? Thank you in advance :)

That is a correct, and usually preferred way to connect a button. The tutorials on official site are not always the best ones around. Both will work and will not damage the Arduino.

In instructables tutorial an internal pullup resistor is used instead of an external pulldown used in official tutorial. There are certain benefits to using this approach, such as lower part count and avoidance of taking a 5V line to the button which reduces the risk of accidental short circuit. There is also one drawback - the logic is somewhat less intuitive. When the button is not pressed, digitalRead will read HIGH, and when the button is pressed, it will read LOW.

You enable the internal pullup with pinMode (pin, INPUT_PULLUP);

In fact that is the best way to do things. I discuss the pros and cons here:- http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Can I connect buttons like that without damaging my Arduino?

You certainly can and should connect buttons in this fashion, with one minor caution. You just need to be careful not to accidentally define the pin to which the button is connected as an output. The built-in pullup function is enabled by writing the port to HIGH - as if it was an output - while it is actually set as an input. If it was written HIGH and was defined as an output, then pressing the button would put a short circuit across that output and potentially damage the chip (to say nothing of not being able to respond in the correct way to a button press.)

Why doesn’t anyone do it like that?

Well, that depends on the definition of “anyone”, doesn’t it? Those who are competent in electronic engineering (whether or not possessing an academic qualification) would almost always do it in the manner described. Those describing it otherwise tend to be less competent. This unfortunate phenomenon is expressed in a popular aphorism.

And those who can't teach, teach teachers. Have you ever come across teacher training lecturers?

Thank you for your replies! I'm a veterinary but I've always studied programming languages as a hobby and now that I discovered arduino I wanto to get into electronics but I don't even know where to start... Using arduino is so simple even I was able to make something out of it but now that my projects are becoming more complex I feel the need to understend what I'm doing as opposed to the "let's try this and see if it works" attitude :)