From an old HP ink jet printer I salvaged a linear actuator assembly. This assembly consists of a DC motor, sliding rods, a carriage, toothed belt connected to the carriage and an optical linear encoder with the corresponding sensor on the carriage.
The sensor on the carriage is connected to the interrupts of the arduino, so no pulse is missed. By keeping track of the pulses the carriage knows where it is.
A H bridge motor controller is used to actuate the DC motor, this moves the carriage.
A simple control loop was made to have the carriage more back to a set point on the actuator.