

A limit switch is an electromechanical device designed to detect the presence or absence of an object or the position of a moving part. It operates by making or breaking an electrical connection when a physical actuator is engaged. Limit switches are widely used in industrial and automation systems to control machinery, ensure safety, and provide feedback on mechanical movements.








The pin configuration of a limit switch depends on its contact type. Below is a general description for a standard SPDT limit switch:
| Pin Name | Description |
|---|---|
| COM | Common terminal. Connects to the power source or signal input. |
| NO | Normally Open terminal. Connects to the load when the switch is actuated. |
| NC | Normally Closed terminal. Connects to the load when the switch is not actuated. |
Below is an example of how to connect and use a limit switch with an Arduino UNO:
// Define the pin connected to the limit switch
const int limitSwitchPin = 2;
// Variable to store the state of the limit switch
int switchState = 0;
void setup() {
// Set the limit switch pin as input with an internal pull-up resistor
pinMode(limitSwitchPin, INPUT_PULLUP);
// Initialize serial communication for debugging
Serial.begin(9600);
}
void loop() {
// Read the state of the limit switch
switchState = digitalRead(limitSwitchPin);
// Check if the limit switch is pressed
if (switchState == LOW) {
// Limit switch is pressed (NO terminal connected to GND)
Serial.println("Limit switch activated!");
} else {
// Limit switch is not pressed
Serial.println("Limit switch not activated.");
}
// Add a small delay to avoid spamming the serial monitor
delay(200);
}
The limit switch does not respond when actuated:
The Arduino reads inconsistent or noisy signals:
The limit switch wears out quickly:
Q: Can I use a limit switch with AC power?
A: Yes, many limit switches are designed to handle both AC and DC power. Check the voltage and current ratings of your specific model.
Q: What is the difference between NO and NC terminals?
A: The NO (Normally Open) terminal connects to the load when the switch is actuated, while the NC (Normally Closed) terminal connects to the load when the switch is not actuated.
Q: How do I protect the limit switch in outdoor environments?
A: Use a limit switch with a high IP rating (e.g., IP65 or higher) to protect against dust and water ingress. Additionally, consider using a protective enclosure.