This project puts a servo motor through its paces, using a library unit I've written. The unit takes care of assigning the proper duty cycles and frequency to the associated degree positions of the shaft.
I'm using a Tower Pro SG-90 servo motor here. It's available for less than four bucks from Amazon, which is where I bought mine. There are only three connections: ground, +5V and a control line.
If you're not familiar with these devices, here's the dope. The microcontroller should spit out a pulse wave and vary the duty cycle. For this particular motor, the frequency of the signal is 50 Hz. By experimentation and observation, I noted that a pulse width of 825 microseconds brings the shaft to its 0-degree position, while a pulse width of 2550 microseconds spin it to the 180-degree position.
Click to get the source code.
Click to get the schematic PDF.
Next Project: Unipolar Stepper Motor #1