HOWTO Analog contact switch?

Thank you all for your great help in the past. I'm trying to build a contact switch so my Drawbot (http://marginallyclever.com/drawbot) can auto-center after being calibrated.

I have a wire to 5v and another to A0 with exposed leads. I expected A0 would report LOW most of the time and HIGH when the pen holder bridges the leads. I'm getting weird bouncing, sometimes even when I'm not touching the leads. I've checked that there is no accidental contact between the leads.

Please. What am I doing wrong? In a perfect world I can get this to work without having to add resistors. I don't mind the bouncing so long as it only happens when I'm bridging. Thank you!

I expected A0 would report LOW most of the time and HIGH ...

No with nothing connected that is what you will see it is called a floating input.

In a perfect world I can get this to work without having to add resistors

Enable the internal pull up resistors and connect the switch between the input and ground. These work on analogue inputs as well as digital ones. Although you can use the analogue pins as digital ones.

The input pin is floating, voltage level subject to whatever is around.

"In a perfect world I can get this to work without having to add resistors." But this is reality, with CMOS parts needing very little current to change their voltage level.

Solution: Wire your switch from A0 to Gnd. Then read it:

byte contactswitch = 14; // D14 = A0 on '328 chips

pinMode (contactswitch, INPUT);
digitalWrite (contactswitch, HIGH); // turn on internal pullup resistor. there is no pulldown resistor.

if (digitalRead(contactswitch == LOW){
// switch is closed, do some action
}

Add debounce code if you need it.