A switch is connected to PortA.1 and PortA.2.
The shaft will be at the middle position first. When switch_A is pressed, it'll move one step to the left. When switch_B is pressed, it'll move one step to the right.
Servo Motors are Actually used for precision control. And so is their use in robotics. Can you please describe in detail how to control the amount of movement on either side.
This is not a super accurate positioning control program. It's more like RC car or joy stick control.
The servo motor position is controlled by the input pulse width. If you read my program , you'll find that each time a button is pressed the pulse width is adjusted by +/- 80uS. The starting position is in the middle. So each time a button is pressed, the shaft is moved away from the middle position by the pulse width of 80uS.