How Do I Add Limit Switches and Safety Interlocks to My Arduino Actuator System?
External limit switches define safe travel bounds in software, while safety interlocks prevent hazardous conditions such as running without a load, double-activating, or operating when a guard is open. This article shows how to implement both.
External Limit Switches in Arduino Code
Connect NC limit switches to Arduino digital pins (with INPUT_PULLUP). When the switch is untriggered (closed), the pin reads HIGH. When the mechanism reaches the switch (opens it), the pin reads LOW — stop the motor.
%2014.19.15.png?width=623&height=361&name=Captura%20de%20Pantalla%202026-03-10%20a%20la(s)%2014.19.15.png)
⚠️ Check limit state before every move Always read the limit switch state at the beginning of a move command. If the switch is already tripped, don't start the motor — the actuator may already be at the boundary and commanding extension could force it against a physical stop.
Safety Interlocks
An interlock prevents motion unless a specific condition is met. Common examples: a door/guard switch that must be closed before the actuator can move, or a weight sensor that prevents extension if no load is present.
%2014.20.16.png?width=624&height=281&name=Captura%20de%20Pantalla%202026-03-10%20a%20la(s)%2014.20.16.png)
Watchdog Timer for Hung Motion
Add a software timeout to detect if the actuator gets stuck (mechanical jam, broken limit switch wire) and fails to reach the target within an expected time:
%2014.20.52.png?width=623&height=323&name=Captura%20de%20Pantalla%202026-03-10%20a%20la(s)%2014.20.52.png)