Extending PWM output pins with a Texas Instruments TLC5940 LED driver


Microcontrollers like the Arduino were designed to facilitate the use of electronics for designers and DIY enthusiasts. The interface provides a great starting points for a variety of elecronic circuit designs. However, as the microcontroller is standardized, it is also limited in its use. That shows for example in the limited number of PWM (pulse width modulation) enabled output pins.

What can you do to extend the PWM capabilities of your Arduino? Just buy a bigger one? That is not necessary anymore after you have read this article. Here it is shown how to connect an Arduino microcontroller to a Texas Instruments TLC5940 LED Driver to connect a large number of LEDs, or even power-intensive devices such as star-mounted high power RGB LEDs or servo motors.

In the design of digital musical instruments (DMIs), this is particularily useful to provide different kinds of feedback to the performer while maintining high extensibility at a lower cost.

Disclaimer: This information and the circuits are provided as is without any express or implied warranties. While every effort has been taken to ensure the accuracy of the information contained in this text, the authors/maintainers/contributors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.


The datasheet of the TLC5940 is available from Texas Instruments, amongst other useful information such as application notes and the option to request samples.

A selection of important features:

Number of channels 16
Resolution 12 bit (4096 steps)
Drive Capability 0 mA to 120 mA (for VCC > 3.6 V)

Connectable actuators

Many electrical components can be controlled using a PWM signal. Not only LEDs can be dimmed, but also Servo motors can be driven, as well as DC motors.

Daisy chaining

Daisy chaining means that you can wire multplie devices together in series. In our case, we can not only extend the PWM pins with one TLC5940 with 16 pins, but because of the daisy-chain ability even use multiple TLC5940s to output 32, 48 or 64 PWM signals.


The wiring of the TLC5940 will occupy 4 PWM pins on the Arduino for the serial communication to the chip. Depending on your Arduino, you will have to look up the according pins that have to be connected. The tlc5940arduino Arduino library provides additional information (e.g., connecting an Arduino Mega). Please read the comments to each scheme, as there are a few mistakes in the showed pin setup.

Pin names and numbering on the TLC5940.

Generally, the MOSI pin is connected to the TLC SIN, SCK to SCLK on the TLC, OC1A to XLAT, OC1B to BLANK and OC2B to GSCLK. In addition, the TLC's DCPRG should be connected to VCC (rather than to GND) to disable the on-chip EEPROM dot-correction and enable the dot-correction from the DC-register in the device that can later be used with the Arduino library. The VPRG pin on the TLC can be connected to ground when the standard “greyscale” PWM register should be used, as opposed to connecting this pin to the Arduino's digital pin 8 to use the dot-correction functions in the library. This pin is optional and you can leave it on GND for now. The TLC's XERR pin can be used to check for thermal overloads if you connect it to digital pin 12 on the Arduino.

In order to daisy chain two or more TLC5940, connect the SOUT of TLC 1 to the SIN of TLC 2, and the SCLK, XLAT, BLANK and GSCLK and proceed in that manner for every additional TLC5940.

A 10k pull-up resistor connects the TLC BLANK to GND. This is necessary in order to turn off all outputs while the Arduino resets, so that they do not ”float“ (it would output the voltage difference between two not ground-referenced signals – basically noise). It is only necessary to add this resistor to the first TLC5940 in the daisy chain, as the BLANK pins are connected.

The IREF pin of every TLC5940 has to be connected to VCC through a resistor. The resistor value has to be calculated according to the output current that is suitable for your application. If you want to connect components that draw 20 mA of current (such as standard LEDs), use Ohm's law to receive the resistor value:

R = V / I \\
R = 39.06 V / 0.020 A \\ 
R = 1,953 ≅ 2k

For those who want to know where the number 39.06 comes from: As the output current of the TLC5940 is set by a current mirror by taking the reference current (that is determined by a resistor from an on-chip 1.24V voltage reference) and multplying it with a nominal gain of 31.5 you get 1.24 x 31.5 ≅ 39.06!

Please study this breadboard layout for connecting 32 LEDs to your Arduino. Note that output pins 0 and 15 of the TLC5940 are on the opposite site of the other output pins.

Breadboard wiring of two daisy-chained TLC5940 with an array of LEDs.

Control circuit

An Arduino microcontroller is limited in its output current to 40 mA, while it should probably not be driven at maximum. Overall, you should not draw more than 200 mA current from the Arduino as that is the processor chip package current.
If you need to drive high power consuming devices, you should design a control circuit and a work circuit. The control circuit, which is driven with a low current, will tell the work current when to let current flow to your connected devices. This is accomplished through the use of transistors. For every output pin that you want to control separately, you'll need a PNP transistor.

Note: Don't pick an NPN transistor, as the TLC5940 is a constant-current sink and the current has to flow towards the output pins. As a PNP transistor's base pin will connect the collector end emitter pins when current is drawn from is, as opposed to the behaviour of an NPN transistor, that switches when current is applied to the base pin.

Make sure that you get a PNP transistor that switches quickly and operates at the TLC5940's output current of 20 mA. You can verify this by looking on the graphs in the transistors datasheet. The work circuit is only connected with the Arduino through the transistors and operates at a higher current auch as 400 mA. If you would connect a star-mounted high power RGB LED such as a this model from Vollong, you will need to connect a resistor between the emmitter and the diode. The resistance value is calculated as follows:

R = (supply voltage - diode voltage) / (diode current)\\
e.g., \\
R = (5 V - 2.5 V) / (0.4 A) = 6.25 Ohm\\

You should choose the resistor that is nearest to the off-rounded value of that number.

Choose the power supply according to the amount of Watt needed by the connected devices. You can calculate the power of each device by multiplying the voltage and the current and then sum the results.

Breadboard wiring of a TLC5940 acting in a control circuit for driving high power circuit elements through transistor-switching a work circuit.

These simplified schematics show a single high power LED connected via a PNP transistor to the TLC5940.

 Schematic for a corntrol and working circuit controlled high power LED

Arduino Code

For the Arduino code, please refer to the well documented tlc5940arduino Arduino library written mostly by A. C. Leone. After putting the downloaded folder into the library folder inside the Arduino folder, example files will be available under the File > Example section in the Arduino IDE.
The Example file BasicUse.h will guide you through the most important library features. Basically, the TLC has to be initialized in the setup statement of the code (Tlc.init()). Then, you can set the value of each output pin in a for loop by accessing Tlc.set(channel, value) where channel is 0 to 15, and value is 0 to 4095. Tlc.update() is then used to actually send the set values to the TLC5940, whereas Tlc.clear() sets all values to zero without sending them.
An important thing to know is that if you want to use multiple TLC5940s, you have to set their quantity in the file ”tlc_config.h“ in the library's folder. Open the file with your favorite text editor and replace the value of the constant NUM_TLCS with the amount of TLCs you're using. Save the file and restart the Arduino IDE.

Servo motors have to be controlled differently than common LEDs. Fortunately, the tlc5940arduino library provides a way of doing so without having to change much code. The example file Servos.ino explains how you should connect a servo motor and shows the use of custom library functions such as tlc_initServos().
Be aware that you cannot use LEDs and servo motors with the same TLC5940 (either if daisy-chained), as the use of the latter fuction will drop down the PWM frequency to 50 Hz (which will be significant for the LEDs).


The circuit is useful for connecting any large number or actuators to your device. For example, you could imagine giving visual feedback to user interaction on different interaction locations. An array of individually PWM controlled LEDs that can even be faded gradually can be accomplished using the TLC5940.

An array of individually contollable servo motors could be used for many purposes, as servo motors are very accurate, quite fast adjusting their angle and versatile due to the available servo accesoirs such as horns and rods.

Additional Information

Sparkfun sells a TLC5940 Breakout board for a reasonably low price (currently $12.95 where the TLC5940 alone is at about $8).


This document provided an introduction to the TLC5940 LED driver, details on its capabilities and applications and practical information on its implementation and use with the Arduino library.

Fritzing files

Fritzing is an open-source software distribution for designing breadboard layouts and much more. You can download these zipped Fritzing .fzz files to get a better understanding of how to wire it up.


The contained Frizing file TLC5940_control_circuit.fzz requires the Adafruit Fritzing Object library as an exotic object is used (the high power LED).