Again, there is no such thing as "not 0 or 1" in digital. It IS either 1 or 0. I don't get how you will get a state of "not 0 or 1".
OK, ADC. Does ADC_Read() give out codewords or just a high or low (0 or 1)? I'm just assuming here, but from what I see, ADC is used for ANALOG, not digital. Getting an input from an analog pin won't give you ONLY 1 or 0. It will give you an integer codeword(commonly ADC in MCUs have Vref=5V, unipolar). If the MCU uses 10-bit ADC, then HIGH is 1023(voltage = Vref) and LOW is 0.
but in third estate always LED3 ON
So no matter what you do with the switch, LED 3 is always ON? This is probably because the pin is now configured as analog.
I'll tell you again, if you want digital, there are only
TWO states. There is no such thing as third state. It's either ON or OFF. No more, no less.
Regarding the switch SW1, please help me here. This is how I understand the switch.:
Pin 5 is the common pin in the switch.
If the top-most slider is turned on, pin 5 will short with pin 1 which is connected to 5V? Right?
Like wise, turning on the second to the top slider means connecting pin 5 to pin 2 which is connected to ground.
Am I right?
Now, what you want to ask here is if you turn top most slider ON, LED 1 will light and LED 2 and 3 are off. (because pin 5 is connected to 5V)
Next, if you turn slider 2 on, LED 2 will light up while 1 and 3 are off. (Because pin 5 is now connected to ground)
Finally, if you are referring about the
"third state" as both of the sliders are on, you are SHORTING 5V with ground and that is VERY VERY bad. Furthermore, PORTC.0 will have a random value (either 1 or 0) which you don't have any control over.
But if I'm wrong about my first assumption about the switch, then it must be your lucky day. You won't have to re-solder a new voltage regulator, yay!