The position of the servo motor is set by the length of a pulse. The servo expects to receive a pulse roughly every 20 milliseconds. If that pulse is high for 1 millisecond or less, then the servo angle will be zero, if it is 1.5 milliseconds, then it will be at its centre position and if it is 2 milliseconds or more it will be at 180 degrees.
"Continuous" Servos, also called "360 Servos" work very similarly, so you can use them just like a position servo. Instead of the absolute position, a continuous servo will adjust its speed with different pulse widths
This example uses the PWM feature of the GPIO library to generate the pulses for the servo. The PWM frequency is set to 60 Hz so that the servo will receive a pulse roughly every 17 milliseconds.
Last updated on May 04, 2015
Published on Jul 15, 2013
The length of the pulse is changed by adjusting the duty cycle over the fairly narrow range of 3 to 14.5 percent. These figures were estimated and then tweaked a bit to give a maximum range of the servo being used.