This is something we have been asked a lot about. How do I control a ton of Servo motors with my arduino? Well… using the TLC5940 is one way. And this nice break outboard from sparkfun makes connecting a ton of servos easy. The output pins on the board are all setup and spaced to allow you to just solder some male headers to it and plugin some servo cables.
Why Do I need something special to control them?
First off, if you don’t know why something special is needed to control extra servos, let’s go over a few basic things. A simple RC Servo (most smaller servos in the sub $20 range) is a DC motor that knows its rotation position, and is most often limited to moving 180 degrees. You can instruct one of these servos to move to a specific degree (0-180) using PWM, Pulse Width Modulation. (Seriously, click the link to get a better visual understanding of what it is). On the arduino you usually think of this as analogWrite. Well, because there are only a few PWM pins on your arduino, if you want to control more servos than you have PWM pins, you need something like the TLC5940.
You can think of the TLC5940 as PWM pin multiplier because it needs a few PWM pins to operate correctly, but it gives you back a bunch more. If you were wondering, no, it can’t add PWM capabilities to a controller that has no PWM pins.
Hooking it up
Hooking the TLC5940 up to your arduino is a little more complicated than most, but if you follow the diagram, you will be all set.
The power supply isn’t always necessary, and you could connect the VCC pin to the 5V pin on your Arduino. But, if you plan on moving more than a couple of the Servos at a time, you will need an extra power supply, and yes, it must be 5V (and remember to connect the external supply ground to the arduino’s ground as shown in the illustration). If you don’t use a power supply, and you use too much power by moving too many of the servos at a time, you can cause the Arduino to restart due to power failure, and you will just get a bunch of twitching servos.
chaining them together
If you need more PWM/Servo connections, you can chain the TLC5940s together. Just connect another board’s input pins to the output pins of the first and you are good to go.
The code for this board is a bit on the complex side, so it uses a library to make your life easier. Im going to do something a little unordinary here. The library is just a little too big to work well with our code delivery system. But you can download the library here (zip file).
To make this code work, before you load the code, or even open the Arduino program, you will need to place the downloaded “Tlc5940” folder (see above for link) into your Arduino Library. If you don’t know where your libraries folder is by default, Look to the right.