Pages: [1]   Go Down
Author Topic: 9V, 3 way switch and arduino digital pins  (Read 1156 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have a three way switch that needs to turn a 9V battery on / off and switch between digital i/o pins on a Seeeduino. The switch should do something like:

[state 1 - off] [state 2 - on, and digital pin x] [state 3 - on, and digital pin y]

The problem is not with turning the power on and off, but when connecting up the i/o pins, as the above method will connect the i/o pins to the 9V battery - which I think will ruin the board (the max it can take is 5V +/- 0.5V). Therefore, do I need to use 7805 Voltage Regulators, 1 for each i/o pin connection?

Has anyone used these? Will 2 of them significantly reduce the battery power / time of the 9V battery? If so, are there any other ways of doing the above?

Cheers,
Lee.
Logged

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

Quote
Has anyone used these? Will 2 of them significantly reduce the battery power / time of the 9V battery? If so, are there any other ways of doing the above?

I'm sure there is but it's not clear to me at all what you are trying to accomplish. Maybe a drawing would help? Is the "2 of them" meaning two switches?

To sense a digital input from a switch requires no external voltage at all wired to the switch, just enable the internal pull-up resistor for the input pin and wire the switch's two terminals between the input pin and ground.

 
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using a switch for two purposes you should get a double-pole triple-throw (DP3T) switch.  Then you would not be mixing power and logic signals.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

retrolefty, johnwasser - thanks.

johnwasser - Thanks, I'll bear that in mind for next time, but I still have the problem for the components I'm being forced to used now. If it helps, I'm currently using this component:
http://uk.rs-online.com/web/p/products/337-481/

retrolefty, "2 of them" = 2 7805 Voltage Regulators. If it helps, you can find a sketch of the electronics at the link below (sorry if it's confusing, I'm not an electronics expert), it's based on the component linked above that has 8 pins:
http://www.flickr.com/photos/73829717@N06/6654435543/in/photostream

Thanks,
Lee.
Logged

SW Scotland
Offline Offline
Edison Member
*
Karma: 17
Posts: 1404
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't need the regulators, simply use a pair of potential dividers, each comprising 2 x 10k resistors in series.  This will give around 3.8 volts into your arduino if you retain the input diodes.  However these pair of diodes are not necessary so eliminating them will give 4.5 volts to your inputs.   Top side of each divider chain goes to your slider switch poles, bottom side of each goes to a commoned 9v -ve and arduino ground.  Centre of each potential divider goes to your 'X" and "Y" input respectively.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That switch is 2 pole 3 throw according to the data sheet. Therefore, you can use one of the poles to switch the 9v power on when it is in positions 2 and 3 but not 1. You can connect the other pole to ground and connect positions 2 and 3 to Arduino inputs, and enable the internal pullup resistors on those inputs. No need for any other external components at all.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SW Scotland - Thanks, I've had a look into that and it could be a viable way around this problem.

dc42 - Thanks, I understand that. The only thing I'd be concerned using your suggestion is the 9V connection going straight to the i/o pin / ground, as both the poles are connected - would this not break the board? If so, should I just put a resistor on the i/o connections, or do something similar to SW Scotland's idea?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah sorry - maybe that's my misunderstanding - are both the poles 'not' connected?
Logged

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

Quote
as both the poles are connected


Both poles are only connected mechanically, that is they move to the same terminal positions at the same time as you manipulate the switch. However the two pole terminals are completely electrically isolated from each other and what voltage is wired and used on one pole has no bearing to what voltage can be wired and used on the other pole.

That make sense?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

dc42 - Thanks, I understand that. The only thing I'd be concerned using your suggestion is the 9V connection going straight to the i/o pin / ground, as both the poles are connected - would this not break the board? If so, should I just put a resistor on the i/o connections, or do something similar to SW Scotland's idea?

I'm not suggesting you connect 9v to an I/O pin (you mustn't do that!). I'm suggesting you use one of the poles of the switch to connect ground to an I/O pin when the switch is closed and let the internal pullup resistor pull it up to +5v when the switch is open. Use the other pole to switch the 9v supply. The key is that the switch has two separate poles, isolated from each other.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

retrolefty, dc43 - brilliant - that makes perfect sense! I didn't realise the poles of this switch weren't 'electrically' connected, so that's where I was going wrong.

Thanks - I think you've all helped solve my problem, quickly too smiley

Lee
Logged

Pages: [1]   Go Up
Jump to: