Dumb input button/pull-down resistor question

So in most of the tutorials for the Arduino, they use a 4-pin PCB-mount push button with a 10k Ohm pulldown resistor. I’m wanting to do the same thing but with a 2-pin push-button, but I’m having a bit of a derp moment with wiring a pull-down resistor. It is essentially done as in the attached schematic, so in the normal (open) state the Arduino would read a low/0v, and when pushed (closed), Arduino would read high/5v, yes?

Yes, that is correct.

The pins on those 4-pin buttons confuse the carp out of me- could never remember which pins were always joined, and which are switched.

Anyone using them may find the attached pic helpful…

switch2.jpg

Can always put a meter on the switch & confirm what is connected.

I prefer using the internal pullup resistor so an open switch reads high, and then short the pin to Gnd by pressing the button.
Then any miswiring is not likely to connect +5 to Gnd.

JimboZA:
The pins on those 4-pin buttons confuse the carp out of me-

What worked for me was realizing inside is basically two staples. Staples like what used to hold papers together. On through-hole parts, it is obvious which are connected because the legs of the "staple" curve towards each other.

On surface mount parts, the stable generally runs across the long edge.

The pins on those 4-pin buttons confuse the carp out of me- could never remember which pins were always joined, and which are switched.

Always take the wires from two opposite corners then it doesn't matter how much rotation is on the switch it is still the correct two wires.

I prefer the pull up resistor method see here for why:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Grumpy_Mike:
I prefer the pull up resistor method see here for why:-
Inputs

Seconded.

Add to list of "advantages": You don't need any extra resistors!

Grumpy_Mike:
Always take the wires from two opposite corners then it doesn't matter how much rotation is on the switch it is still the correct two wires.

Good thinking, Batman

Grumpy_Mike:
I prefer the pull up resistor method see here for why:-
Inputs

Huh, it hadn't occurred to me that you could use the internal resistor like that. That's really cool and makes life much easier.

Just remember though that the internal resistor is a pull-up, while your original post spoke of pull-down, so the high / low logic is reversed when you go the internal route.

Grumpy_Mike:

The pins on those 4-pin buttons confuse the carp out of me- could never remember which pins were always joined, and which are switched.

Always take the wires from two opposite corners then it doesn't matter how much rotation is on the switch it is still the correct two wires.

Very good suggestion. :slight_smile: I'm kinda bummed that I didn't also think of that. =(

I prefer the pull up resistor method see here for why:-
Inputs

I fear I'm about hijack this thread... But... I had a quick read-through and want to commend you on a well written article. I did notice two things.

This can be done with a single pole change over switch (or SPCO).

In my electronics training over here in the states, we never used that term. We called that a SPDT (single pole double throw) switch. Thinking about it, though, I do remember hearing that term when reading about PLCs and industrial ladder logic motor controls, so it may also be an industry thing. You might want to add SPDT if you can work it in w/o removing any of the elegance of your article, since many of us will see SPDT instead of SPCO when looking for parts online.

Also, I don't know if you want to muddle your wording by mentioning that in Arduino1.0+ instead of sending a digitalWrite high after defining the pin as input, one can just define it as an INPUT_PULLUP. One less line, and more intuitively describes the intended action of the line of code.

But it's your (well written already) article to edit or not edit as you choose. :wink:

Thinking about it, though, I do remember hearing that term when reading about PLCs and industrial ladder logic motor controls, so it may also be an industry thing.

Well it is what I was brought up calling them in the U.K. in the 60s.
Still good points both of them.
Web page amended- Thanks. :slight_smile:

Grumpy_Mike:

Thinking about it, though, I do remember hearing that term when reading about PLCs and industrial ladder logic motor controls, so it may also be an industry thing.

Well it is what I was brought up calling them in the U.K. in the 60s.
Still good points both of them.
Web page amended- Thanks. :slight_smile:

No problem. My training is about 30 years later than yours (90's), and on a different continent. Terms change over time and across regions. Do you still use "milliard" where I would say "billion"?

Edit: P.S. the edits look good.

JimboZA:
Just remember though that the internal resistor is a pull-up, while your original post spoke of pull-down, so the high / low logic is reversed when you go the internal route.

Yep, no worries, just means I'll need to swap some highs and lows around in the programming, and saves on external components (always nice on a crowded prototype board).

Remember also if you use a pull down resistor, make sure the pin is definitely configured as an input in software. If it is set as an output inadvertently and you write a LOW to the pin, the output will sink excessive current, possibly damaging that bit. You could possibly have a pull up and pull down resistor with a ratio to give the required 3 volts for a high at the input?

No that also applies to a pull up resistor as well, if the output is set high and the switch is made.

I you want to protect against the twin errors or miss configured outputs and putting the wrong logic level then add a series 120R resistor to the arduino pin to limit any current flowing through the pin to safe levels.

I never do this.