Very often when designing some sort of mechanical assembly you want your widget to move a part across a specific area. But moving too far, it could damage itself. This is why linear actuators are popular. You can apply a voltage to it and it will extend all the way out but not far enough to damage itself.
Inside of every linear actuator is a gear motor, a threaded rod, and a pair of limit switches and diodes. When the gear motor spins, it rotates the threaded rod which ends or retracts the shaft of the linear actuator. To prevent damage to itself from extending or retracting too far, a limit switch and a diode are used at each end.
When the limit switches are not thrown your motor power can move freely in each direction. When you’re moving up and hit the limit switch at the top, it breaks the circuit and cuts power to the motor. In order to be able to back off of the limit switch we need a way to allow electricity to flow around the limit switch but only in the opposite direction. This is what the parallel diode provides for us.
A useful tool we have to make this easy to use with any gear motor is our DPDT and SPDT Relay Board (TE-010-502). This allows you so connect your limit switches, motor, and motor power directly to the board and control the motor direction using two digital outputs from a microcontroller or Single-Board-Computer like an Arduino, Raspberry Pi, or Beagle Bone Black.