Newbie question: switch inteference with hand position?

Hi --

I'm getting started with Arduino, and having some trouble working with the pushbutton. My goal is to substitute a switch that I bought at an electronics store for the pushbutton bundled in the kit.

I do get the sample pushbutton sketch to work on the breadboard using the example DigitalReadSerial sketch as described here: http://arduino.cc/en/Tutorial/DigitalReadSerial (10KOhms pull-down resistor I believe)

But when I remove the pushbutton to substitute an action switch, the serial monitor values become erratic, and in fact seem to trigger "1" simply when my hand approaches the breadboard. I then loosely wire in the switch (Philmore Mini Snap Action Switch with Long Lever) into the breadboard, running 2 jumper wires from former the locations of the pushbutton (which I removed) to "COM" and "NO" on the switch. The result: I read "0" as expected when the switch is not pressed, then "1" when I press it. But the values remain "1" when I release, I think because the presence of my hand is triggering it. When I remove my hand, after 4-5 seconds, the values settle back to "0".

I think I'm not understanding a basic principle, maybe related to "pull down", but I would have thought that simply substituting a switch for the pushbutton and leaving the rest of the setup intact would be reliable. What am I missing? Thanks for any tips and suggested reference pages.

Best regards,

Brad

I think I'm not understanding a basic principle, maybe related to "pull down", but I would have thought that simply substituting a switch for the pushbutton and leaving the rest of the setup intact would be reliable

Would have thought so too... provided you have the pull-down resistor still in place?

Its purpose is to ensure that the pin is low when it's not high. That might sound crazy, surely if it's not high it must be low?- nope. Pins "float" and really need to be deliberately forced to either end of the scale. Just because it's not high, doesn't mean it is low, so the resistor as the name implies, pulls it down to 0.

But it has to be through a resistor, not just a piece of wire... if it was just wire, when the switch was closed, the 5v would short circuit straight to 0v with the unavoidable release of expensive smoke.

Best you post a schematic of what you have...

Are you using a solder-less breadboard? I suspect the problem might be that you were using a simple SPST push-button switch that has four terminals and switching to a simple switch using just two terminals your resistor is no longer wired into the circuit. Again the universal language of electronics is the schematic drawing, anything else is subject to misunderstanding or incorrect assumptions being made.

Lefty

Ah, thanks for both replies! Yes, I was using the solder-less breadboard and four terminal pushbutton as described. Moving all the leads to the same side of the breadboard did the trick, and the external switch is working reliably as expected.

(Now I can continue with my weekend project: a detector to determine when the flying squirrels have exited through the one-way door in the roof! Thanks again).

-Brad