Simple switch and arduino

Hi,

This is a really newbie questions, thanks for bearing with me :)

I was planning to use this kind of micro switch:

http://www.freeflightsupplies.co.uk/images/P1140034.jpg

I would need to detect movement of something. I think this just connects two cables together when it is clicked. Can I read that kind of thing into Arduino, if I just connect this - should it be "analog in" or "digital in" side?

Thanks for help,

Jukka

This is a simple pushbutton. You just hook one side to an input pin and to ground through a 10k resistor. Then hook the other side to the +5 volt pin. The sketch will then be used to tell when you push the switch.

Look at the StateChangeDetection sketch in the Arduino's example section under Digital. It explains hoe to hook it up and use it to turn on an led. It should give you a good idea of how to use it.

Hi..

I was having the same problem but now seems to be solved.

The parallel 10kohm connection doesnt work in many cases, and the analog pins still fluctuate when the signal is off. This can be bad when you need not only a 1 but also a steady 0.

Heres what I did: If you are using a breadboard, connect the two main ground lines of the bread board(blue lines) together. (one of them is connected to your arduino ground, right?) Then, hook up the "other" ground line to the "second" ground port of your (hopefully new) arduino. This way your "analog in" will remain steady at NOT zero, but at a constant value..which you can at least convert to a "zero" in your program.

But theres a soltn to that too...use the digital in of Arduino and you should get a 0 and 1 with no more fluctuations, provided you are running your breadboard the way I described above.

Hope this helps you. :D

donot forget to debounce http://www.arduino.cc/en/Tutorial/Debounce :)