9V, 3 way switch and arduino digital pins

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.

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.

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.

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:

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.

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.

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.

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?

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

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?

Chattoux:
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.

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 :slight_smile:

Lee