Limit switch, lever microswitch
COM rests on NC and moves to NO while the lever is held. The robot limit switch.
- 3 pins
- 1 setting
- In 19 projects
- In 2 lessons
The Limit switch, lever microswitch in brief
What it is, and every setting the properties panel gives it.
A lever microswitch is the limit switch on 3D printer end stops, robot bumpers and conveyor ends: a small black body with a steel lever and three tags, COM, NO and NC. The KW11-3Z and Omron D2F are this part. It is a changeover, not a plain button: at rest COM touches NC, and pressed it touches NO. The simplest wiring needs no resistor, COM to ground and NO to an Arduino Uno or ESP32 pin set to INPUT_PULLUP, so the pin reads LOW at the stop. Printers wire NC instead, so a broken wire reads as triggered and the motor stops rather than grinding. Mokxi models break before make, with the blade touching neither contact for 200 microseconds, then bounce on the contact it lands on: with bounce set to typical, the default, each press or release is 3 to 7 edges settling within 1 to 5 milliseconds, so a sketch that counts presses without debouncing miscounts exactly as on the bench. Lever force and travel are not modeled; hold the mouse on it when the axis would arrive.
- Family
- Inputs
- Pins
- 3
- bounce
- typical (or none)
3 pins
Named as the editor names them, so a wire lands where you expect it.
COM while the lever is up.COM while the lever is pressed.How to use a limit switch with an Arduino
Use COM and NO. COM goes to GND and NO to a digital pin set to INPUT_PULLUP, so digitalRead() gives LOW while the lever is pressed and HIGH the rest of the time. The bumper car here has two, left on pin 7 and right on pin 8, and backs away from whichever side reads LOW. Hold a switch with the mouse to bump it.
The contact bounces when it lands, so a sketch that counts presses, rather than just reacting to the level, needs to ignore changes for a few milliseconds after each one. A 3D printer wires its end stops to NC instead, so the pin reads LOW until the stop and a broken wire looks like a hit rather than letting the motor grind.
An ESP32 or a Pico reads it the same way, COM to ground and NO to any input with its pull-up turned on.
const int BUMP_LEFT = 7;
const int BUMP_RIGHT = 8;
void setup() {
pinMode(BUMP_LEFT, INPUT_PULLUP);
pinMode(BUMP_RIGHT, INPUT_PULLUP);
}
void loop() {
if (digitalRead(BUMP_LEFT) == LOW) {
// hit on the left: back off and turn right
}
}What is true about the Limit switch, lever microswitch, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
- The changeover:
COMonNCat rest, onNOwhen pressed. - Break before make, and bounce on the contact it lands on.
Not modeled
- 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.
From Limit switch (lever microswitch), in full.
See the Limit switch, lever microswitch in a project
19 built-in projects use it. Each opens in the editor, already wired.
Where it turns up in a lesson
2 lessons place it in their own circuits.
The boards it is shown on
Each of these 3 boards has a built-in project with the Limit switch, lever microswitch in it.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Limit switch, lever microswitch
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.