Limit switch (lever microswitch)

A lever microswitch with COM, NO and NC tags: the limit switch on robots, printers, turntables and conveyors.

A small black box with a steel lever along the top and three tags underneath. It is the end stop on a 3D printer, the home switch on a turntable, the bumper on a robot car and the switch a box presses at the end of a conveyor. The KW11-3Z and the Omron SS and D2F are all this part with different levers.

Hold the mouse on it to press the lever.

Pins

Pin What it does
COM The moving blade.
NC Normally closed: joined to COM while the lever is up.
NO Normally open: joined to COM while the lever is pressed.

It is a changeover. A pushbutton only makes a contact; this one moves COM from one contact to the other.

Wiring it

The usual way needs no resistor: COM to ground and NO to a pin set to INPUT_PULLUP.

pinMode(7, INPUT_PULLUP);
if (digitalRead(7) == LOW) {
  // the lever is pressed: the axis is home, or the bumper hit something
}

Printers wire their end stops to NC instead. The pin then reads low all the time and goes high at the stop, so a broken wire looks like "at the stop" and the motor stops rather than grinding.

Bounce

The blade leaves one contact before it reaches the other, and then bounces on the one it lands on. With bounce set to typical, a press or a release is 3 to 7 edges that settle within 1 to 5 ms, inside the 5 ms maximum Omron gives for its miniature switches. A sketch that counts presses has to debounce them, exactly as it would on the bench. Set bounce to none for an ideal switch.

What the model gets right

  • The changeover: COM on NC at rest, on NO when pressed.
  • Break before make, and bounce on the contact it lands on.

What it does not model

  • The lever's travel and force: it is pressed while you hold it.
  • A machine pressing it. Nothing on the canvas moves into it, so the hand is the mechanism: hold it when the axis would have reached it.

See it in a project

The Bumper car uses two as front bumpers.