I want to use a three way toggle switch to let the user select two modes of operation and also switch off the Arduino completely (to save power). I'm using an Uno R3, in case that is relevant.
The switch is type B from here: http://www.maplin.co.uk/sub-miniature-toggle-switches-2341
When the switch is in the middle "off" position none of the three pins are connected. When in either "on" position (left or right) the middle and left or right pins are connected.
I have completed a test circuit where the state of the switch is read (left position on one digital pin, right on another, both using pull up registers), and two different LEDs are illuminated, one for each switch position (the LEDs were connected to other pins and controlled by the program). With the switch in the middle position both LEDs are off.
That was the easy part. Now I'd like to connect a battery (using a snap on 9V battery connecting to the DC barrel jack), with the switch between the battery and the DC barrel. When the switch is in either on position, I want the Arduino to get power but also read which way the switch is toggled so that the program can operate in one of two different modes. I understand the digital in must not be connected the +9V on the battery, but could I interrupt the ground connection from the Arduino to the battery with the switch, joining each pin to ground and the left and right ones to a digital pin for input?
Or is it just not a good idea to mix the power with the logic pins? I feel there is either a fundamental gap in my knowledge here or I'm trying to do something that isn't possible! :~
I have considered using the switch to control the two modes and a separate switch for power, but I see this as a more elegant user interface.
Any help greatly appreciated.