pull up resistors

Hey,

Something that bothers me,
When connecting a button to an arduino, I understand that a pull up resistor makes sure there won't be an open end when the button is unpressed which will might cause a bad reading, but on the same time it seems that if there will be no resistor, the bigger problem will be a short between the 5 volts going to the button, to the ground (when the button is pressed), am I right?

Thanks

511568b7ce395f613f000004.jpg

You can leave off R1 and just wire the switch to connect the pin to Gnd when pressed.
Use the internal pullup resistor on each pin:

pinMode (pinX, INPUT_PULLUP);

The input does look like a resistor to Gnd, R2 = ~1 Megohm. The internal pullup is ~30-50K ohm and will hold an open High just fine.

Thank you for the answer, but I am trying to understand the logic behind it (without using the internal pull up resistor), in the circuit in the picture, does the R1 has to be there to prevent short? (in case of no use the internal arduino's pullup resistor)

Three examples shown here, there is no short to +5 if pull up is removed:

Yes, R1 can be external as you pictured, or internal. In both cases +5 can not be shorted to Gnd.

Thank you guys

something else about the same case, In the attached diagram, when the button is unpressed, I saw one website that says the arduino would get a 5v but wouldnt it be less than 5 volts because of the voltage drop on the resistor?

511568b7ce395f613f000004.jpg

Let's say R1 was 10k.
The input resistance for the input gate is extremely large so the input current is next to nothing.
Therefore, almost zero current X 10k gives almost zero voltage across the 10k (R1).

VR1 = 0ma X 10k = 0V

Hence the voltage at the input must be 5V
.

I see, so I understand that actually on every input pin I will have a very low current? (because of high input resistance)

Yes, 1uA (microAmp) max per the datasheet.

1uA * 10k = .01 volts

Vin = 4.99 volts

This is how to do it without resistors, and also why a resistor makes it simple.Inputs