Multiple pushbuttons and pulldown resistor

So I have three pushbuttons each with a +5v input, output to pin via resistor and a pulldown resistor to ground. They work great but I'm wondering if I wouldn't be able to just use 1 pulldown resistor to stop them from floating or if this would cause them to not function properly if they were pressed concurrently. If they were not meant to be pressed concurrently, is this a safe thing to do?

If this is a stupid question and this is not logical thinking is there some proper way to do this? 3 pushdowns with a shared pulldown?

In cases like this, it is helpful to look at a schematic of what you are trying to do.

Notice that pin2, pin3, and pin4 are all effectively on the same piece of wire? So when one of the buttons is pushed, they will ALL see 5V. No, you can't use a "shared" pull-down resistor.

However, why not use the internal pull-up resistors instead? Then you don't need any external components. The only trade off is that the logic is inverted (unpushed buttons are HIGH and pushed buttons are LOW.)

Ah, I see what you're getting at. By using the internal pullup resistor I can sidestep the external resistors. Would this have any implications for battery life, though, since I would now have to supply a constant 5v except for when the button connection is broken (open) and electrons diverted?

It seems like almost every Atmel chip has support for internal pull-ups so it's also future proof should I decide to switch chips. Great solution, thanks!

SilentDirge:
Would this have any implications for battery life, though, since I would now have to supply a constant 5v except for when the button connection is broken (open) and electrons diverted?

In order for power to be burned you must have both Voltage AND current. Holding a pin up with 5V (nearly) eliminates current from flowing just the same as when tied to ground. So while you are applying a constant 5V, so little current is flowing that the Power is practically Zero. (In the P = I * E you don't use 5V. You use 5V-induced voltage which is practically zero.)

Incidentally, when using a pull-down the same reasoning applies. Keep in mind that if current starts to flow there is a voltage, even a small one. So you burn the same amount of power using a pull-up as a pull-down.

Virtually no current flows until the button is pressed. Once it is pressed, the current is the same whether it is a pull-up or pull-down.

If you are worried about power consumption it is a very good practice to enable the Pull-Up resistors on ALL unused I/O pins. Otherwise, floating pins can draw over 1mA of current. Which, on a device that only consumes 20mA is pretty significant.

1 Like

With the internal pullup, the swithes aren't connected also. All they share is ground, so you can press 1 and 2,3 see nothing.

If you are worried about power consumption it is a very good practice to enable the Pull-Up resistors on ALL unused I/O pins. Otherwise, floating pins can draw over 1mA of current. Which, on a device that only consumes 20mA is pretty significant.

Interesting, I had no idea! Very good to know.

One last question for you then; right now I'm using those buttons to trigger an interrupt on the arduino on any difference in the interrupt pin they are all connected to (H->L or L->H). Other than changing the pin to be an input (to avoid a short) would I even need to change anything else to maintain the interrupt functionality?

No, just create the interrupt on a Low level instead of High.

If you are worried about power consumption it is a very good practice to enable the Pull-Up resistors on ALL unused I/O pins. Otherwise, floating pins can draw over 1mA of current. Which, on a device that only consumes 20mA is pretty significant.

I know this is an old thread but can somebody please elaborate on this. Does this mean all unused pins should be grounded to lower power consumption? If so, would this also mean one has to be extremely careful not to set a pin as output inadvertently, otherwise you run the risk of an overcurrent on that pin?

Better option is to set unused pins to input with internal pullup resistor enabled.
This stops any floating or oscillating, and pins can be pulled high/low by outside forces and not hurt anything.

Is there any other technique of doing this.If we are doing this way the resistor might degrade on variation in temperature. If we using analog read pin to read data .The value may not same at start and in actual field.
let me know other technique

No this is about Digital I/O. We are not measuring a voltage so the ACTUAL value of the resistor is not critical. The pin is looking for a logic change from 0 to 1 on a keypress.

The drawing is flawed. Any keypress will be the same as ALL keys being pressed since the inputs... by means of sharing a resistor... are also all shorted together.

It's time we all started loving resistors for the very useful job they do for us.

It's time we all started loving resistors for the very useful job they do for us.

And time to also love not needing to use any external resistors at all to read switch contacts as the AVR chip gives us optional internal pull-ups to use so there is no reason to not just utilize negative logic and use the internal resistors.

Lefty

The drawing is flawed.

No, it's not, since the point that you make pwillard:

Any keypress will be the same as ALL keys being pressed since the inputs

is exactly the point that James was making when he posted that sketch.

i understood above concept like this.

if any of 3 switch has been triggered particular digital pin goes high
Assume i have connected to analog pin. Due to variation of resistor it start reading analog values.depend on analog read signal i can able to judge which mode i need to go..

Reviving this old thread again! Sorry!
In ref to the above diagram, people have said that with a shared resistor, one button push would make all pins read +. if there were 3 resistors instead, wouldnt all 3 pins still be connected thru ground or shorted and still read +?
AKA How does the diagram in the earlier posts differ from this one:

And is this first one any different from :

Well, the two diagrams are equivalent, but the glaring problem is the suggestion that you might apply 12V to an Arduino pin. :astonished:

In addition, the matter is moot. Good design is that given we are connecting switches and not some other device, and have the option of how we can wire them, then they should all be connected to ground and making use of the internal pull-ups of the AVR chips rather than external pull-ups, let alone pull-downs.

Thanks for the response!

Lol. Whoops Those all should have been 5V. I was doing it on my phone, and forgot to change the other two power supplies to 5V.
The reason I'm asking about this is b/c i'm trying to recreate this: http://www.instructables.com/id/Make-a-Fire-Breathing-Animetronic-Pony-from-FurRea/?ALLSTEPS.

The pull down resistors aren't exactly a part of the arduino circuit. So I was wondering why they put in all those pulldowns (Step 15), instead having all of them connect through one pulldown resistor.

EDIT: I should add that i've read other posts indicating that you need pulldown for each pin. But I guess I don't understand why that's the case. Put another way, if there is a pull down for each pin, everytime you you flip the switch it seems like the current will still feed into the other pins with or without resistors for each pin. Or is it that a resistor with each pin creates a "path of least/most resistance" situation, so the current would go into ground instead of feeding through the additional resistors into the other pins??

EDIT 2: Okay, I think the path of least resistance thing is why you need multiple resistors and not a single one right before ground. I just watched this video that -- while not specifically talking about single/multiple pulldowns -- suggested why multiple pulldowns were needed due to the path of least resistance concept.
The video I watched: Electronics 201: Pull-Up and Pull-Down Resistors - YouTube

Thanks again for the help! Please correct me if I've got this wrong and might be leading others the wrong way too!

-Sigh-
I really wish he hadn't said current would "take the path of least resistance". And, "current is lazy." What the hell?!

No. Current will take any path as if the other path wasn't even there. The thing you are missing is that there must be POTENTIAL difference in order for current to flow. Another word for potential is "voltage".

bringing this up from the grave. just started with arduinos,

i'm making a blinker control box for my motorcycle and whenever i hook to the inputs without a pulldown resistor it gets a constant signal from all 3 even when no controls are activated.

i hooked up a pulldown resistor similar the the first picture in this thread with all 3 running to the same resistor, but.... i have a diode on each leg before it reaches the resistor, now, when i say turn on left signal, all 3 still get a signal. i then went through 3 different 10k resistors onto the same ground wire, again, all three are getting a signal.

please help.