Reading J Blum's book Exploring Arduino I came across the following code and schematic. Can anyone explain why
a resistor between pin 2 and +5V is not needed?
Paul,
I am a newbie, so bear with me.
When the switch is closed and the pin2 is low, the 5V pin is connected to pin2 by a piece of wire. There is
nothing to limit the current flow between these two pins. I am assuming that low = 0 V. It looks like a short to me.
x50505:
Paul,
I am a newbie, so bear with me.
When the switch is closed and the pin2 is low, the 5V pin is connected to pin2 by a piece of wire. There is
nothing to limit the current flow between these two pins. I am assuming that low = 0 V. It looks like a short to me.
I didn't see the image in your first post because it was in powerpoint format (I think).
When a pin is set as INPUT it has a big resistor in there. Megaohms so it's not a short.
But...using external pulldown resistor is just silly. AVR chips have internal pullups for this, you don't need extra external components.
Using external pulldowns is also bad design. Your feeling is correct - it can lead to short circuits if you're not paying attention or something goes wrong. Internal pullups and switches that go to GND are a much safer way to do it.