We have controlled a Servo Motor using PIC16F877A. The Servo Motor works on the principle of Pulse Width Modulation. Usually a servo motor operates between 0 and 180 degrees. However, it could be hacked to rotate continuously. There are several documents available over the internet on hacking a servo. Here, we have used three different ON time pulses of 0.9 ms for the 180 degree position, 2.1 ms for the zero degree position and 1.5 ms for the neutral position. A servo motor has a cycle time of 20 ms.
Usually the servo motors are controlled using internal timers. However, the use of timers requires knowledge of interrupt flags and register. To avoid complexity, we have used a delay function. Happy servo motoring!