How to connect  toggle switch

Can I connect this type of toggle the same way as a push button? hope someone can help me. ;)

To make a long answer short..... Yes.

;D

You would hook it up the same. Use the center terminal and one of the outside terminals.If you want it to act like a push button, get a momentary toggle switch, otherwise it will just be On-Off.

Hope this helps.

Dan

Thanks a lot! So if i do it like this it will work as a On-Off?

Thanks a lot for your help

Two points.

One this looks like a three position centre off switch.

Two you are much better off swapping the switch an resistor. That is having the switch connect the input to ground with the input pulled up to 5V by the resistor. You get much better immunity from noise this way round.

Just to simplify (or complicate depending on your point of view) you could use the switch across ground and an input pin and activate the internal pullup resistor. Saves a resistor, an extra line of code in the sketch. If you're sticking with a physical resistor, I'd go for a 10k resistor, if only for the reason that 5mA of current doing nothing would break my heart............. ;)

the reason that 5mA of current doing nothing would break my heart.

Two points:- 1) It is only 5mA when the switch is on. 2) It is not doing nothing it is giving you noise immunity. What price a reliable design?

500 uA gives me adquate noise immunity and many of my circuits spend a lot of time 'switched on' :)

10K pullup is good enough for the arduino reset system, its good enough for me......

If you read the data sheet you will see the reset pin has different input characteristics that the others. Still it's your choice.

Hey guys Im very new at this, Could anybody explain me all that 5mA 500uA 10k pullup please???

Ohm's Law V=IR. V = 5V, R = 1K, therefore I = 5 / 1000 = 5mA. V = 5V, R = 10K, I = 5 / 10000 = 0.5mA or 500uA

Wo! thanks If I connect a toggle switch like shows in that diagram by Vajnavi I have less immunity from noise and if I connect it with the resistor going to the 5v instead of ground i get more immunity? wich one is better? :-? thank you guys ;)

See reply #3 in this thread. Grumpy does know what he's talking about. :)

Hey Thanks! I just want to be sure of what you guys are sayin cus english is my second language and im a bit confused. Is this what you mean grumpy? or anyone? thanks! Danke!

Thats correct.

Offtopic: What are you using to create that image? Have you heard about Fritzing. Great little tool for designing and documention your arduino porjects. http://fritzing.org/

Makes it easy to draw up you idea like you have done and show it.

What are you using to create that image?

Thanks for your help! i aprecciate it! I made it with Photoshop very easy to use, thankyou for sharing Fritzing Ill check it right now! Peace ;)

Errrmm, the switch should be between gnd and pin 2, as it is pin 2 will always be low and the switch will just turn current through the resistor on and off (nothing in other words).