What We’re DoingSpinning a motor is good fun but when it comes to projects where motion control is required they tend to leave us wanting more. The answer? Hobby servos. They are mass produced, widely available and cost anything from a couple of dollars to hundreds. Inside is a small gearbox (to make the movement more powerful) and some electronics (to make it easier to control). A standard servo is positionable from 0 to 180 degrees. Positioning is controlled through a timed pulse, between 1.25 milliseconds (0 degrees) and 1.75 milliseconds (180 degrees) (1.5 milliseconds for 90 degrees). Timing varies between manufacturer. If the pulse is sent every 25-50 milliseconds the servo will run smoothly. One of the great features of the Arduino is it has a software library that allows you to control two servos (connected to pin 9 or 10) using a single line of code.

Servo Not Twisting? Even with colored wires it is still shockingly easy to plug a servo in backwards. This might be the case.

Still not WorkingA mistake we made a time or two was simply forgetting to connect the power (red and brown wires) to +5 volts and ground.

Fits and StartsIf the servo begins moving then twitches, and there’s a flashing light on your Arduino board, the power supply you are using is not quite up to the challenge. Using a fresh battery instead of USB should solve this problem.

Making it Better?

Potentiometer Control:
We have yet to experiment with inputs but if you would like to read ahead, there is an example program File > Library-Servo > Knob. This uses a potentiometer (CIRC08) to control the servo. You can find instructions online here: http://ardx.org/KNOB

Self Timing:
While it is easy to control a servo using the Arduino’s included library sometimes it is fun to figure out how to program something yourself. Try it. We’re controlling the pulse directly so you could use this method to control servos on any of the Arduino’s 20 available pins (you need to highly optimize this code before doing that).