How many servos you need to control?

     Those who intend to build a more complex project (in this case I mean with more DOFs, like a hexapod, biped humanoid and others) may find dificulties if using a Arduino UNO or similar board, unless they have a Mega. That's what happened with me when I was working on my biped project.

     After researching a lot of alternatives, without changing the board, I found this IC: TLC5940.

     This is sold as a 16 channel LED driver, but with this library it can control 16 servo motors easily as the "sweep servo". But not only that, the IC can be daisy-chained and expand the PWM outputs even more (I haven't yet tried it, but seems to be very easy). What you lose of your board are 5 pins.

     You can find this IC in a breakout board and also in a shield (PWM shield), or make your own with very low cost (less than USD 2,00 per chip). If you live in Brazil you can buy 20 chips for the price of one PWM shield. :)

     Well guys, what you'll need to make this work are below:

  • Arduino board (I utilized UNO);
  • 1x TLC5940 IC (16 channels);
  • 2.2k resistors;
  • jumpers;
  • external power for the servos;
  • jumper wires;
  • protoboard;
  • servos (how many you want to control or your project needs);
  • musics.


     In my example, I utilized only 6 servos. But you can easily add more on the remaining channels.



     Owwwww... What a mess of wires! It's a bit difficult to understand the connections on the above pic. Because of this I made a schematic in Fritzing. But before it, let's take a look in the IC pins.



     Now, let's go to the connections... Follow the color and pins sequence below.




  • IC pins 1 until 15 and pin 28 are the output channels, where you connect the signal wire of the servo. You got to add a 2.2k pull-up resistor in each channel and connect to 5V to make it possible to control servos.
  • IC pin 16: XERR (non utilized in this case).
  • IC pin 17 - SOUT (non utilized in this case).
  • IC pin 18 - GSCLK: BROWN wire connected to the Arduino pin 3;
  • IC pin 19 - DCPRG: connected to 5V;
  • IC pin 20 - IREF: put on it a 2.2k resistor and connect to GND;
  • IC pin 21 - VCC: connected to 5V;
  • IC pin 22 - GND: connected to GND;
  • IC pin 23 - BLANK: ORANGE wire connected to the Arduino pin 10;
  • IC pin 24 - XLAT: YELLOW wire connected to the Arduino pin 9;
  • IC pin 25 - SCLK: BLUE wire connected to the Arduino pin 13;
  • IC pin 26 - SIN: GREEN wire connected to the Arduino pin 11;
  • IC pin 27 - VPRG: connected to GND.


     As you will utilize a bunch of servos, you'll need an external power supply for them. Don't forget to connect the ground of the servo power to the Arduino power, to make a common GND.

     Note: In the begin I was having troubles to make the servos turn from 0 to 180º, they only turned from 0 to 90º. I researched in many forums and found some guys with the same problem. But nobody had the solution. After changing some values in the tlc_servos.h file, I solved this trouble. So, if someone have this same problem, change the SERVO_MIN_WIDTH from 204 to 120 and the SERVO_MAX_WIDTH from 410 to 475.

     For now, that's all guys.

Can this IC be used if SPI

Can this IC be used if SPI is used for other things like SD Cards?

At first I thought this was

The chip of Adafruit 16- Channel is better , it uses 2 pins only and it works 16 servos’. The TLC5949 IC needs 5 pins. I had made one shield for arduino with 2 4017 for my robot but the Adafruit’s shield is the best for servos …I have problem sometimes with the 4017 chips.

You could

Yes, you could write a software SPI that shifts out the data on another pin. Or you could use a multiplexer to switch the SPI pins between your SD card and some other device.

This guy make IC control up

This guy make IC control up tp 34 servos. Anyone tried before?

SPI defines a Chip Select line.

Using that line allows you to control which device you are talking to. There should be no need for software SPI code.

Nice tutorial

Sparkfun has a nice breakout board and shield for this chip, very useful and saves you a hell of a lot of jumpers :).

I bought the breakout for my quadruped a couple months back but ran into the same problem with the servos only going 90 degrees. I played around with the SERVO_MIN_WIDTH and SERVO_MAX_WIDTH values but was never able to get it perfect (ie, 0 and 180 worked but 90 was at around 100 degrees) which proved to be problematic with my inverse kinematics equations. I eventually gave up and switched to an Arduino Mega. How accurate were you able to get yours tuned to?

Thanks, gdgt.

The breakout and shield of Sparkfun are nice. I plan to make my own homemade pwm shield. The positioning of my servos is very accurate. I test them with three positions (0, 90 and 180) and it answered very good. Have you tried with my values?

Vary in accord to the servos???

Something interesting that I have found today ( This guy utilizes HXT900 servos and he says his MIN and MAX values are 177 and 571. What kind of servos you utilized?


I was excited about this IC after reading Dickels post. I bought two of them. In my setup I read and stream music from a SD Card using SPI. I use PWM as output to the speaker. I wanted LED’s to do some light show to the music. Streaming the music involves using timers. Running TLC5940 with SPI also involves using timers as I understand it. It’s not easy to run TLC5940 without using libraries as tlc5940arduino. I haven’t tried bitbanging the IC yet, but I would think this also involves the use of timers.

I got TLC5940 working using SPI, and on the same hardware setup, I can read the SD Card with SPI. But all my LED’s are flickering as crazy when I read SD Card data. Not the kind of light show I had in mind.

So maybe I will save the TLC5940 for some other projects unless I find a good example utilizing both SD Cards and TLC5940.

Anyway, thanks for making me aware of this IC.