so what you want to do is have a minimum and maximum angle for the arm and clamp the direction between these two angles.