Looking for some help in stopping this motorized potentiometer midway

to test this code, copy and paste the code to a new sketch and use the serial monitor to see if its working,
you could send a,b,or c. could you take a video of it so that i know how to amend the code to be more efficient. Its hard to write a code for something that i cant see.