arduino PWM - Pulse Width Modulation PWM with a TLC5940


The TLC5940 is a handy item to have when you run out of PWM ports on the Arduino. It has 16 channels, each individually controllable with 12 bits of resolution (0-4095). An existing library is available at It is useful for controlling multiple servos or RGB LEDs. Just keep in mind, the LEDs must be common anode to work. Also, the chips are daisy-chainable, allowing even more PWM ports.


// Include the library
#include <Tlc5940.h>

void setup() {
    // Initialize

unsigned int level = 0;
void loop() {
    // Set all 16 outputs to same value
    for (int i = 0; i < 16; i++) {
        Tlc.set(i, level);
    level = (level + 1) % 4096;
    // Tell the library to send the values to the chip