MarkT:
Connect one side of the switch to ground, connect the other to the pin
Next task will be learning to solder and performing debouncing in software I think.
I already included software debouncing, but the thing is that the switch has 3 pins, what is the center pin for then ?
It's a mechanical switch - it makes no difference. If you have a multimeter with a diode test function, or if you build a little led circuit using the Arduino's 5v and gnd pins, then you can figure all this out for yourself. You wont break anything.
bwat:
It's a mechanical switch - it makes no difference. If you have a multimeter with a diode test function, or if you build a little led circuit using the Arduino's 5v and gnd pins, then you can figure all this out for yourself. You wont break anything.
Okey cool thanks for the help I was afraid for my Arduino :*
SilenT612:
Okey cool thanks for the help I was afraid for my Arduino :*
I understand. Yesterday I accidentally shorted some pins on my LCD when I got clumsy with an oscilloscope probe. Thankfully it only seemed to reset my Uno- nothing broken.
If you always have a spare 9v battery around, then you can quickly build little test circuits to figure out how a component works without risking your Arduino or anything else expensive.
Using the code above in Reply 1 from MarkT, connect the center pin to ground and connect one of the other two pins to pin 2 of the Arduino. Done.
Which of the outer pins on the switch that you connect to, depends on which one of the toggle switch positions you wish to be closed. Flip it one way, the center pin is connected to the outer pin on the opposite side.
Here is an illustration of why toggle switches generally seem to work backwards as compared to slide switches:
polymorph:
Using the code above in Reply 1 from MarkT, connect the center pin to ground and connect one of the other two pins to pin 2 of the Arduino. Done.
Which of the outer pins on the switch that you connect to, depends on which one of the toggle switch positions you wish to be closed. Flip it one way, the center pin is connected to the outer pin on the opposite side.
Here is an illustration of why toggle switches generally seem to work backwards as compared to slide switches: