Newbie, cannot get switches to work.

I am a high school student trying to set up some switches to work with the arduino. Unfortunately they refused to cooperate, so we set it up to graph two analog inputs. It seems that when one switch is on, the other inputs all get 50% more voltage, for instance if one and two are plugged in and three is turned on, one and two register 2.5 volts, and if 4 is turned on too it registers 3.75 volts. Below is the diagram of the circuit.

Red is the number of the switch and blue is the input.

Oddly enough, this one, which we use for our first input, works fine and is wired the same way, while the other switches are like this and do not work.

I don’t think I soldered it up wrong, but I can’t figure out why it won’t work.

As drawn in your posting they should work just fine, with no interaction between switches. Are you sure you wired them up as you have drawn them?

Have you maybe by accident turned on internal pull-ups on your digital input pins? Also pins 0 & 1 also wire to the FTDI serial chip so there might be voltages on those pins interacting with your external pull down resistors?

Lefty

I've gone over them so many times, I am 99% sure they are done like the diagram. As for the pull ups, I don't know. I haven't been the one programming it, but I don't think we are using pull ups, I'll check tomorrow. I do know we haven't been using digital 0 or 1.

Actually, I think I may have the 2nd to last resistor wired on the ground rather than before it... That would do it. I'll check tomorrow and hopefully come back to explain how dumb I am. If its not that, I think there's something going on with the toggles.

It took me a few times of messing up before I got used to using the switches!

Here's some examples for setting up a pull-down resistor on them, this includes pictures so you can check your own: http://www.arduino.cc/en/Tutorial/Button http://www.ladyada.net/learn/arduino/lesson5.html

The second one has a good picture that explains the legs.. for some reason, to this day.. I still hook them up wrong sometimes!(I think I'm getting old!:D)

I really can not figure out why a single-pole, single-throw, momentary contact switch needs 4 legs. A lot of switch related problems would be resolved by having only 2 legs.

I really can not figure out why a single-pole, single-throw, momentary contact switch needs 4 legs

Lots of small button momentary contact switches have four legs - it probably makes them easier to machine-assemble, and makes them more stable on the PWB.

If you dont have the pullups turned on, the pins will have a high resistance, and will tend to follow the pins next to them.

The 10k resistors in the pic arent doing anything useful, only limiting current through the switch.

If you are going to have the resistors (instead of using internal pullups), connect them between the cpu and ground or vcc.

If you connect them to ground, make sure you turn off the internal pullups.

The 10k resistors in the pic arent doing anything useful, only limiting current through the switch.

Are you sure of that statement? They look to be perfectly wired external pull-down resistors wired between ground and their associated digital input pin to me.

Using external pull-down resistors are just as valid as using internal pull-ups, just results in a different default logic state of zero instead of one, while both prevent floating input pin condition.

You are right, I read it wrong. The pictured schematic should work fine as long as the internal pullups are turned off.

Okay, so the problem was I had another 10k at the end of the ground which was making the current go back into the inputs. :-[ Thanks to everyone who offered advice and got me to learn about the built in resistors, no more externals and tons of soldering for me. ;D