skip navigational linksPJRC
Shopping Cart Checkout Shipping Cost Download Website
Home MP3 Player 8051 Tools All Projects PJRC Store Site Map
You are here: Teensy Teensyduino Libraries Tlc5940

PJRC Store
Teensy 3.1, $19.80
Teensy 2.0, $16.00
Teensy++ 2.0, $24.00
USB Cable, $4.00
Teensy
Main Page
Teensy 3.1
Getting Started
How-To Tips
Code Library
Projects
Teensyduino
Reference

Tlc5940 Library

Tlc5940, by Alex Leone, interfaces with one of more TLC5940 chips from Texas Instruments. Though expensive, each chip provides 16 PWM outputs with 12 bit resolution, and built in current limiting for directly driving LEDs without resistors.

Download: Tlc5940.zip (version r014_2, with modification for Teensy 3.x)

Tlc5940 works on Teensy 3.1, Teensy 3.0, Teensy 2.0, Teensy++ 2.0, and Teensy++ 1.0.

The special servo motor mode (tlc_servo.h) only works on Teensy++ 2.0, and Teensy++ 1.0.

Hardware Requirements


Tlc5940 test board. Wiring details shown below

The TLC5940 chip (PDF) requires only 2 resistors and connects to Teensy using 5 signals.

SignalTLC5940
Pin
Teensy 3.x
Pin
Teensy 2.0
Pin
Teensy++ 1.0
Pin
Teensy++ 2.0
Pin
GSCLK185911
BLANK*234152626
XLAT243142525
SCLK25712121
SIN26622222
VPRG, GND27, 22Connect to GND
DCPRG, VCC19, 21Connect to +5V
IREF20Connect 2.2K resistor to GND
Must be
output mode
--02020
Unusable
as PWM
--424, 2724, 27
* The BLANK pin should have a 10K resistor connected to +5V.

Several TLC5940 chips may be used. The SOUT signal (pin 17) of each connects to the SIN (pin 26) of the previous chip, and GSCLK, BLANK, XLAT, SCLK are connected in common to all chips.

Example Programs

Tlc5940 includes several examples, available from the File > Examples menu.

File > Examples > Tlc5940 > BasicUse

File > Examples > Tlc5940 > Fades

Peripherals Used

Tlc5940 uses the SPI port and 2 timers. The MISO pin is not used. The SS pin may only be used as an output. Timer1 and Timer2 are used on Teensy++. On Teensy, Timer1 and Timer3 are used. Some PWM pins associated with these timers are either used by the library. The others may be used as input or output, but not as PWM (analogWrite).

Wiring and Pinout Info



Details

For more details, please refer to the official Tlc5940 page, or this older page.

For development on Tlc5940 for Teensy, please refer to this Github repository:
https://github.com/PaulStoffregen/Tlc5940