1

I am playing with this basic example:

Arduino: Button

enter image description here

There're a lot of existing questions about why to connect button to the ground. I get the idea more or less. Is done to avoid "noise" during reading the input value.

However, what I don't understand is why to use resistor instead of a wire? If I remove resistor and put the wire instead the example stops working. Could someone explain me this?

2
  • 3
    If you remove the resistor and put a wire then when you press the button you have a dead short to ground. That's sometimes a little more exciting as it tends to cause smoke and sometimes even fire. But it tends to be a one-shot experiment with most Arduino.
    – Delta_G
    May 29 '20 at 3:32
  • There are no existing questions about why to put the resistor there. It's all well known and been done that way for decades stuff. Without it the pin is floating when the button isn't pressed. It isn't connected to 5V and it isn't connected to ground. So it reads whatever voltage it wants based on the noise it picks up. With the resistor, when the button isn't pressed it is connected to ground and therefore reads LOW reliably. It's no mystery and there's no debate about it anywhere except among those who don't know what they talk about.
    – Delta_G
    May 29 '20 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.