How Do I Wire a Limit Switch with Arduino Leonardo

Hi folks! This is my first time building with Arduino, and I only have some knowledge of building/programming through Vex and Robot C. So I appreciate your help. My step sister wanted to build a robot for Christmas, so I bought her the Robot Chassis Kit and we've put it together.

http://www.ebay.com/itm/New-Smart-Motor-Robot-Car-Battery-Box-Chassis-Kit-Speed-Encoder-For-Arduino/371160130577?_trksid=p2047675.c100011.m1850&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20140602152332%26meid%3De273b7599a4e40a688181de78b2de423%26pid%3D100011%26rk%3D1%26rkt%3D10%26mehot%3Dpp%26sd%3D370920371445

We have a Leonardo Board on it and a Motor Shield Board. We have successfully hooked up the external battery power supply and the motors to the boards.

I have bought this limit switch. Where on the Leonardo do I connect it? I know it will be a digital input. Do I connect the Comm prong of the switch to any digital port (1-13)? Do I connect NO on the switch to something on the board?

Thanks folks!

leonardo.jpg

Thanks for those pictures, i always wondered what a leonardo looks like, and a microswitch!

Use the common and normally open terminals on the switch. Wire them to a digital input and ground, either way around. To read the switch, set the digital input to INPUT_PULLUP. Normally the input will read HIGH but will read LOW when the switch is pressed.

Paul

Thank you so much Paul! We will try this soon. :slight_smile: