Pages: [1]   Go Down
Author Topic: Multiple pushbuttons and pulldown resistor  (Read 2409 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6143
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6143
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26569
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26569
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 1
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26569
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

DELHI
Offline Offline
God Member
*****
Karma: 7
Posts: 741
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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



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.)

Logged

AMPS

Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1643
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3882
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The drawing is flawed.

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

Quote
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.
Logged

The Elders of the Internet know who I am.....

DELHI
Offline Offline
God Member
*****
Karma: 7
Posts: 741
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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..
Logged

AMPS

Pages: [1]   Go Up
Jump to: