[Solved] Bizzare Switch/Button behaviour

I can't get a simple switch to work, this is driving me mad.

If I wire it like this: http://arduino.cc/en/Tutorial/DigitalReadSerial each time i press the button the whole Arduino shuts down (on light goes off and use disconnects from windows). This seems like a short circuit to me but I don't know much about this stuff yet. I tried wiring it this way (and I thought this worked the night before): Pin 2 (logic) -> dip switch -> 10k resistor -> ground.

This doesn't seem to do anything. Other strange things that happen: When I touch the wire for pin 2 it reacts as if the button was pressed. Could there be something wrong with the arduino or the components I use (I tried dip switch and push button and new resistor)? I am using the example code for button.

Any help appreciated! :astonished:

each time i press the button the whole Arduino shuts down

This is because you have wired it up wrong and you are shorting out the supply with your botton. 1) You have not wired it up like you describe. 2) What you describe is wrong anyway. It should be:- Pin 2 (logic) -> dip switch -> ground. and also:- Pin 2 (logic) -> 10k resistor -> +5V

See:- http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Thanks! Got it working right away, don't know why it didn't work before, I seem to have tried this... Maybe programming was wrong at a time...