Stepper motor control with optics