Microswitch


Microswitches are useful for detecting passage of a moving part or for implementing an electronic limit stop. Set up the switch so that your mechanism wipes the lever and closes the switch as it moves by.

Here are pictures of typical microswitches.

 

Most microswitches have three terminals labelled C, NO, and NC, standing for Common, Normally Open, and Normally Closed, as shown below.

For regular switch action, connect to the C and NO terminals. The switch will be open when not pressed and closed when pressed.

Interface your microswitch to the Arduino in the usual manner as shown here.

Demo Code

In ME2011 lecture, Durfee has a demo showing a motor driven wheel that stops precisely at a pre-determined position because of a microswitch. The code for the demo is listed here.

Ideas

  1. If you have a turntable that you want to stop at several positions, use a single microswitch and place several bumps on the edge of the turntable where each bump closes the switch as it passes by.
  2. If you want to stop the motion at the beginning and end of travel, use two microswitches wired in parallel. These will connect to one Arduino pin. Although the Arduino can't tell which switch is being depressed, the program will know because it will know which direction the motor is turning in.

Where to Get a Microswitch

Robot store, or Ax-man, or Radio Shack 275-017 (SPDT, 5A contacts, lever arm with roller, $1.99), or many other sources.