Controlling the motion of an atom in an optical cavity