As the arm extends it will flip the toggle switch at the top which reverses the direction of the arm. The arm will then trigger the limit switch to stop the arms motion
Motor
Toggle Switch
Limit Switch
Battery Holder