Using a pull-up in place of pull-down resistor for a switch

Hello,

So my question pertains to the difference in set-up for using a pull-up over pull-down resistor. I know how a simple pull-up resistor based switch looks (using the internal resistors),

.
The pic is from the this example article input pull_up.

My question is the following: Is it necessary to add a resistor between the switch and ground? Obviously the pic has none, but I get the impression from some that having a resistor here could help avoid a possible problem. The only problem I see would be wrongly programming the input pin as a digital output instead and then pressing the physical switch. I’m also looking at a page 228 of Rich Blum’s book Sams Teach Yourself Arduino Programming in 24 Hours (see attachment).

ME-Al: The only problem I see would be wrongly programming the input pin as a digital output instead and then pressing the physical switch.

This is the only problem I'm aware of. I personally don't use extra resistors for buttons.

Yes, you are correct to say that you could accidentally set the pin to OUTPUT and HIGH, then press the button, causing a short which could damage the Arduino. A low value resistor, eg. 330R between the Arduino pin and the switch, would protect you from that series of errors by limiting the current. The fact that you yourself understand that there could be a problem means you are unlikely to make that series of mistakes. We see plenty of people here on the forum that have so little idea what they are doing that they have already damaged their Arduinos by the time they make their first post.

However, to correct your terminology, that extra resistor would not be described as a "pull-down", because it would be in series with the switch and would therefore only affect the Arduino input when the switch was pressed. A true pull-down would affect the Arduino input all the time, regardless of the switch being pressed or not.

Paul

I don't include extra resistors. But my coding is not so poor that I set pins intended to be used as inputs to outputs instead either.

CrossRoads: I don't include extra resistors. But my coding is not so poor that I set pins intended to be used as inputs to outputs instead either.

Just wait when you get old and decrepit. :confused:

ME-Al: Hello,

My question is the following: Is it necessary to add a resistor between the switch and ground?

No, it is not necessary to add a current limiting resistor in series with the switch. But, yes it does make the design "safer" for individuals who are new and are experimenting with the Arduino.

What were the recommended values: 10K Ohms & 160 Ohms ?

ME-Al: Hello,

So my question pertains to the difference in set-up for using a pull-up over pull-down resistor.

IMHO expressed in the simplest of terms, you use an internal pull-up when u are "switching" the negative (i.e GND or 0v) and you use an external pull-down resistor when you are "switching" the positive (i.e. +5V)

Putting a series resistor in an input pin is rather like putting stabilizers on a Harley Davidson. A rather stupid thing to do.

But, yes it does make the design "safer" for individuals who are new and are experimenting with the Arduino.

No it doesn't, if they are that stupid then they will find much easier ways to destroy their Arduino. An output can withstand the odd short short to ground without too much damage.

But if you really really must do something like this then use a resistor that has the smallest possible negative effect and limits the current to 40mA, so that will be a 130R.

mrsummitville: No, it is not necessary to add a current limiting resistor in series with the switch. But, yes it does make the design "safer" for individuals who are new and are experimenting with the Arduino.

What were the recommended values: 10K Ohms & 160 Ohms ?

I wouldn't say that. In my project i had a 6ft run to the switch and the nano was in the engine bay. I had to add a 10kOhm resistor from pin to positive and a 1uF cap from pin to ground, AND i had to create a twisted pair out of the wire to get rid of false triggers caused by noise.

Grumpy_Mike: Putting a series resistor in an input pin is rather like putting stabilizers on a Harley Davidson.

Training wheels to those in the western hemisphere who might not get that joke.

dhtmldude: I wouldn't say that. In my project i had a 6ft run to the switch and the nano was in the engine bay. I had to add a 10kOhm resistor from pin to positive and a 1uF cap from pin to ground, AND i had to create a twisted pair out of the wire to get rid of false triggers caused by noise.

Your 10K ohm resistor from the PIN to Positive is not what the OP was discussing and not what I am discussing. You had a noise problem, you used a capacitor and twisted wire, again not what we were discussing.

Grumpy_Mike:
Putting a series resistor in an input pin is rather like putting stabilizers on a Harley Davidson. A rather stupid thing to do.
No it doesn’t, if they are that stupid then they will find much easier ways to destroy their Arduino. An output can withstand the odd short short to ground without too much damage.

But if you really really must do something like this then use a resistor that has the smallest possible negative effect and limits the current to 40mA, so that will be a 130R.

No, the tutorial did not say, “Putting a series resistor in an input pin”.
The tutorial suggested a low ohm protective resistor in series with the switch.

You say, “without too much damage”.
Any damage, is too much damage.
The series resistor does work and does limit a shorted output to 40ma, as you finally admit.

So what, if there are other ways to destroy an arduino?
You say, “if they are that stupid”.
They are not stupid, they lack experience.
The series resistor does protect the output pin until they gain the experience, then they can remove it.

You say, “Putting a series resistor in an input pin is rather like putting stabilizers on a Harley Davidson.”
No, it is not anything like your ridiculously extreme analogy.
The beginner does get a tricycle.
Then the intermediate person gets a bicycle, with training wheels.
Then advanced person will remove the training wheels, when they are ready.
Then the expert can ride a motorcycle.

The book the OP was reading from, was for the beginner, not for the expert.

Do you not understand, how people learn?
First we crawl, then we walk, then we run.

If the output resistance is 25 ohms then
the protective series resistor can be as low 120 ohms.