A micro limit switch is the small clicky switch that tells a 3D printer, CNC router, gate or lid where a moving part is. They all share a 20mm body, so the real choices are how many pins you need, what sort of arm the moving part pushes on, and which contact you wire. This guide covers those three choices, then wires the switch to an Arduino or ESP32, a printer or CNC endstop plug and a 12V circuit.
In this guide

2-pin or 3-pin: COM, NO and NC
Inside every micro limit switch is one spring contact called COM (common). At rest it touches NC (normally closed). Press the lever past the click and it snaps across to NO (normally open). Let go and it snaps back. A 3-pin switch gives you all three tabs. A 2-pin switch only has COM and NO, so it is open at rest and closed while pressed.
| Switch | Tabs | At rest | Pressed |
|---|---|---|---|
| 3-pin (SPDT) | COM, NO, NC | COM joined to NC | COM joined to NO |
| 2-pin (normally open) | COM, NO | Open | COM joined to NO |
Our lever, roller and 2-pin switches have 1, 3, 2 moulded under the tabs. Hold the numbered face towards you with the lever pivot on the left: pin 1 at the pivot end is COM, pin 3 in the middle is NO and pin 2 at the far end is NC. The 2-pin switch has tabs at 1 and 3 only. The KW11-3Z with no lever has COM, NO and NC moulded above its tabs, with COM at the plunger end.
Pick the 3-pin switch when you are not sure. It does everything the 2-pin does, and the NC tab is the one you want for a machine endstop. For more on contact names, see our momentary vs latching switch guide.
Lever, roller or no lever
The arm on top is called the actuator, and you will also see it called the limit switch arm or head. It decides how the moving part has to meet the switch.
| Actuator | Best when | Our switch |
|---|---|---|
| Straight lever | A carriage, door or cam presses down on the arm. The 16.5mm lever gives a wide target, so the parts don't need to line up exactly. | SC7301, 3-pin, or the KW11-3Z 2-pin lever |
| Roller lever | The part slides along or across the switch, such as a cam, a sliding gate or a drawer. The wheel rolls instead of scraping. | KW11-3Z roller |
| No lever (plunger) | The part presses straight down on the switch in a tight spot, where an arm sticking out would catch on the frame. | KW11-3Z no lever |
A longer arm needs less force to press and gives more room for error, but it trips a little later and less exactly. The bare plunger trips at the most repeatable point, with the least travel, so it suits a Z axis or a lid that closes squarely.
Which limit switch do I need?
| You want to | Choose |
|---|---|
| Add or replace an X or Y endstop on a 3D printer | SC7301 lever, wired NC |
| Home a CNC router or laser axis | SC7301 lever or KW11-3Z roller, wired NC |
| Sense a sliding gate, drawer or cam | KW11-3Z roller |
| Fit a Z endstop or a lid switch in a tight space | KW11-3Z no lever |
| Turn something on while a door or lid is pressed shut, for the lowest price | KW11-3Z 2-pin lever |
| Detect a hatch or door on a 12V boat, caravan or vehicle | Any of them, driving a 12V LED or a relay as shown below |
Wiring to an Arduino or ESP32
A limit switch on a microcontroller needs two wires and no resistor. Wire COM to GND and the other tab to an input pin, then turn on the board's own pull-up resistor with INPUT_PULLUP. The pin reads HIGH while the contact is open and LOW while it is closed. Because the switch only ever connects the pin to ground, the same wiring is safe on a 5V Arduino and a 3.3V ESP32.

For a machine, wire it the safer way instead: COM to GND and NC to the input. Now the pin reads LOW at rest and HIGH when the lever is pressed or when a wire falls off, so the code treats both as stop. This sketch does that. It reads the pin twice, 5 milliseconds apart, so the few milliseconds of contact bounce don't print false changes. Our push button guide has a fuller debounce routine if you are counting presses.
// Micro limit switch test, wired NC: pin 1 (COM) to GND, pin 2 (NC) to D2.
// On an ESP32, use a pin such as 27 and change LIMIT_PIN to match.
// At rest the input reads LOW. Pressing the lever, or a wire coming off,
// makes it read HIGH, so both count as "stop".
const int LIMIT_PIN = 2;
int lastState = -1;
void setup() {
pinMode(LIMIT_PIN, INPUT_PULLUP); // the board's own pull-up resistor
Serial.begin(115200);
}
void loop() {
int first = digitalRead(LIMIT_PIN);
delay(5); // read twice, 5 ms apart, to skip bounce
int state = digitalRead(LIMIT_PIN);
if (state != first) return; // still bouncing, try again
if (state != lastState) {
Serial.println(state == HIGH ? "TRIGGERED: stop" : "clear");
lastState = state;
}
}
Upload it, open the Serial Monitor at 115200 baud and you should see clear. Press the lever and you hear a click and see one TRIGGERED: stop. Let go and it prints clear again. Pull the NC wire off and it prints TRIGGERED: stop, which is exactly what you want a machine to do.
ESP32 pins to use and avoid
- Use GPIO 25, 26, 27, 32 or 33 on an ESP32-WROOM-32 board. They have internal pull-ups and play no part in start-up.
-
Avoid GPIO 34 to 39. They are inputs only and have no internal pull-up, so with
INPUT_PULLUPthe pin floats and reads at random. If you must use one, fit a 10k resistor from the pin to 3.3V. - Avoid GPIO 0, 2, 5, 12 and 15. The chip reads them at power-up, and a switch held closed at that moment can stop the board starting or uploading.
- On an ESP32-C3 SuperMini, keep switches off GPIO 2, 8 and 9 for the same reason. Our ESP32-C3 SuperMini guide has its pin table.
3D printer and CNC endstops: why NC
An endstop tells the controller an axis has reached home or the end of its travel. Wire it NC and a broken wire, a crushed plug or a solder joint that cracks after a few thousand moves all read the same as a pressed switch. The machine stops, or refuses to home, instead of driving the carriage into the frame. Wired NO, the same broken wire reads as "not pressed" and the axis keeps going.

- Use two pins of the plug. Most printer and CNC boards have a 3-pin endstop plug marked S (or SIG), GND and V+. Wire pin 1 (COM) to GND and pin 2 (NC) to S. Leave V+ empty: the switch needs no power, and a switch wired across V+ and GND shorts the board's supply every time it closes.
- Check the plug order on your board. The order of S, GND and V+ changes between boards, so read the labels printed beside the socket rather than copying the old cable's colours.
-
Tell the firmware which way the switch reads. On Marlin 2.1, NC wiring suits
X_MIN_ENDSTOP_HIT_STATE HIGH(the default) and NO wiring needsLOW; older Marlin calls the same settingX_MIN_ENDSTOP_INVERTING. In Klipper, NC wiring isendstop_pin: ^PA1(your pin name), and NO adds a!to make it^!PA1. In GRBL, NC wiring needs$5=1; NO wiring uses the default$5=0. -
Test by hand before the motors move. Send
M119on Marlin orQUERY_ENDSTOPSon Klipper. Each endstop should readopenat rest andTRIGGEREDwhile you hold the lever down. If it reads the other way, change the firmware setting, not the wire.
Long runs on a CNC router pick up noise. Stepper and spindle wiring can flick a limit input for a microsecond and throw a false alarm mid-job. Twist each switch's signal and ground wires together, keep them away from the motor cables, and fit a 100nF capacitor from the input to GND at the board end. If alarms continue, add a 10k pull-up resistor from the input to the board's 5V or 3.3V, so the input is held more firmly than the built-in pull-up holds it.
Using a limit switch on 12V
The rating moulded on these switches, 5A at 125/250VAC, is for AC. On 12V DC, use the switch to send a signal and let something built for the current do the heavy work. When DC contacts open, the arc between them has no zero crossing to put it out, so a motor or a strip of lights switched directly burns the tiny contacts quickly.
| 12V job | Wire it like this |
|---|---|
| Hatch, door or lid indicator light | Switch in the positive feed to a 12V pre-wired LED. Its resistor is already fitted, so it connects straight to 12V. For a bare LED, our LED wiring guide gives the resistor value. |
| Input to an alarm panel, gate controller or PLC | Switch between the controller's input and its common or ground, the same as an Arduino input. |
| Motor, pump, winch, actuator or lights | Switch drives the coil of a 12V relay, and the relay contacts carry the load. A typical 30A automotive relay coil draws about 130 to 150mA. |

- Fuse the switch feed. Take +12V through a small fuse to pin 1 (COM). A 1A fuse covers a relay coil.
- Switch the coil. Wire NO to relay terminal 86 to switch the load on when the lever is pressed. Wire NC instead to switch it off when pressed, which is how a winch or linear actuator stops at the end of its travel.
- Ground the coil. Relay terminal 85 goes to negative.
- Fit a diode across the coil. A 1N4007 from 85 to 86, with its silver band towards 86, soaks up the voltage spike the coil throws when it turns off. Skip it if your relay already has a diode or resistor printed on its case.
- Run the load through the contacts. +12V goes through a fuse sized for the load and its wire to terminal 30, and terminal 87 goes to the motor, pump or lights. Press the lever and you hear the relay click and the load start.
The crimp terminal guide covers the spade terminals that fit a relay base. To add an on/off switch to a 12V panel as well, our rocker switch guide covers hole sizes, ratings and wiring. Keep this to low-voltage DC. For a switch inside mains equipment, fit it in an enclosure and have a licensed electrician do the mains wiring, as NZ law requires for most mains work.
Mounting and adjusting the trip point
- Screws: two M2 screws through the body. Our switches have two mounting holes about 9.5mm apart, which matches most printer endstop brackets made for this 20mm switch size. Larger 28mm switches use a wider hole pattern.
- Solid stop: set the switch so the moving part presses the lever just past the click, then meets something solid. If the switch body is the only thing stopping the axis, the lever bends and the trip point wanders.
- Adjustment: drill or print the bracket with slotted holes, so you can slide the switch 2 to 3mm before tightening the screws. That is how you adjust a micro limit switch. Leave the lever unbent, because bending it changes the force and the trip point.
- Soldering: hook the stripped wire through the hole in the tab, then solder quickly with a hot, clean iron. Holding the iron on a tab for 5 seconds or more softens the plastic, and the switch can stick or lose its click.
- Strain relief: slide heat-shrink over each joint and tie the cable to the frame 20 to 30mm from the switch, so the cable flexes there and not at the solder joint. Thin 26 AWG hook-up wire is plenty for a signal.
Industrial and optical limit switches
Search for "limit switch" in NZ and you will also find much bigger switches. Here is where each type fits.
| Type | What it is | Use it for |
|---|---|---|
| Micro limit switch | 20mm plastic body, lever, roller or plunger, solder tabs | Printers, CNC routers, lasers, robots, lids and hatches inside an enclosure |
| Industrial limit switch | Sealed metal or heavy plastic case, often with an adjustable rod or roller arm and a replaceable head, screw terminals and cable gland | Gates, conveyors, garage doors and machines exposed to dust, oil or weather |
| Optical endstop | A small board with a slotted light gate. A flag on the moving part breaks the beam. | Printers where you want no contact at all. It needs power and its flag must pass cleanly through the slot. |
| Hall effect sensor | A 3-pin sensor that switches when a magnet comes close | Contact-free sensing through a thin plastic wall. See our Hall effect sensor guide. |
We stock the micro limit switches and Hall sensors. For a gate or machine out in the weather, an industrial limit switch from an electrical wholesaler is the right part.
Troubleshooting
| Symptom | Likely cause and fix |
|---|---|
| Endstop shows TRIGGERED all the time | The signal wire is on NC while the firmware expects NO, or the reverse. Change the firmware setting. If it still reads triggered, look for a broken or unplugged wire. |
| Endstop never triggers | The wire is on the wrong tab, or COM is not reaching GND. Check with a meter: COM to NC beeps at rest, COM to NO beeps while pressed. |
| Board resets or the supply cuts out when the switch clicks | The switch is wired across V+ and GND. Move the wire from V+ to S. |
| Serial Monitor prints several changes for one press | Contact bounce. Read the pin twice a few milliseconds apart, as in the sketch above. |
| ESP32 input reads at random | The pin is GPIO 34 to 39, which has no pull-up. Move to GPIO 25, 26, 27, 32 or 33. |
| ESP32 won't start or upload with the switch connected | The switch is on a start-up pin such as GPIO 0, 2, 12 or 15. Move it to another pin. |
| CNC alarm mid-job with nothing touching the switch | Electrical noise on long wires. Twist the pair, route it away from the motor cables and add 100nF to GND at the board. |
| Homing position drifts | The switch body is taking the knock and the lever has bent, or the bracket has moved. Fit a solid stop and check the screws. |
| Switch feels mushy or sticks after soldering | The body overheated. Replace it and solder each tab in 2 to 3 seconds. |
Parts used in this guide
SC7301 lever, 3-pin SPDT$1.75View switch
KW11-3Z roller lever, 3-pin SPDT$1.85View switch
KW11-3Z no lever, 3-pin SPDT$1.59View switch
KW11-3Z lever, 2-pin normally open$1.89View switch
5mm pre-wired 12V LED$0.99View LED
1N4007 diode, for relay coils$0.15View diode
26 AWG hook-up wire, 5m$5.99View wire
Nano V3 USB-C boardFrom $4.99View board
An older KW11-3Z 2-pin switch is on clearance at $1.29. Browse every size in limit switches and endstops.
Frequently asked questions
What is the difference between a micro switch and a limit switch?
A micro switch is the snap-action switch itself. It becomes a limit switch when you mount it where a moving part presses it at the end of travel. Our micro limit switches are micro switches with the lever, roller or plunger already chosen for that job.
Can I use a 2-pin switch as a printer endstop?
Yes. Wire its two tabs to S and GND, then set the firmware for NO wiring. It works, but a broken wire won't stop the axis, so the 3-pin SC7301 wired NC is the better endstop.
Do I need a resistor with an Arduino or ESP32?
Not on a short wire. INPUT_PULLUP turns on the board's built-in resistor. On runs longer than about a metre, or near motors, add a 10k pull-up and a 100nF capacitor at the board.
Will it fit the bracket from my old endstop?
Measure the hole centres on the old switch. If they are about 9.5mm apart on a 20mm body, two M2 screws drop straight in.
Can it switch my 12V motor directly?
Use a relay. The switch drives the relay coil, and the relay carries the motor current, as in the 12V wiring above.
Not sure which one fits?
Message us with a photo of where the switch goes and what presses it, and we'll tell you which actuator suits.
