Coding for autonomous

Hi can i have a coding to make my motor autonomous, please help me i need it asap