I have am using an Arduino Uno R2 and TLC5940 to control a bunch of RGB LEDs. I want to add an Ethernet Shield R3 so that I can control the LEDs over a web-interface. However, the ethernet shield and TLC5940 use many of the same pins. Can I use them together? How?

2 Answers 2


When using multiple SPI devices the normal way to have them share a bus is to assign them distinct slave select lines. The problem here is that although the '5940 libraries use SPI to send data to it, the '5940 is not actually a proper SPI device and so lacks any sort of slave select line.

All is not lost, however. Since the '5940 responds only to SCLK (and GSCLK of course, but you should be running that one separately) all you need to do is inhibit it while nSS for the Ethernet module is active. This can be done with just a little bit of external circuitry. Since nSS must be high in order for the Ethernet module to be inactive, we can AND SCK with nSS to derive SCLK from it.

Using a 74HC08 for this would work, although it leaves 3 of the gates unused. A 74HC02 will let you do it with no wasted gates, but with a slightly higher propagation delay.

And of course, the requirement to clock in the grayscale data before the grayscale cycle completes is still there; properly interleaving this with the Ethernet communications is left as an exercise for the reader.


You can do this with out any additional hardware by putting the TLC5940 to BITBANG mode instead of SPI mode and making the Ethernet Shield use D8 pin instead of D10 pin.

Software Changes

  1. On line 61 of sketchbook/libraries/Tlc5940/tlc_config.h replace



  2. On lines 339 - 341 of arduino/libraries/Ethernet/utility/w5100.h replace

     inline static void initSS()    { DDRB  |=  _BV(2); };  
     inline static void setSS()     { PORTB &= ~_BV(2); };
     inline static void resetSS()   { PORTB |=  _BV(2); };


     inline static void initSS()    { DDRB  |=  _BV(0); };  
     inline static void setSS()     { PORTB &= ~_BV(0); };
     inline static void resetSS()   { PORTB |=  _BV(0); };

Hardware Changes

  1. Bend leg of the D10 pin on the Ethernet Shield so it doesn’t connect to the D10 pin on the Arduino.

  2. Connect D10 pin of Ethernet Shield to D8 pin on the Ethernet Shield D10 pin connected to D8 pin

  3. Connect the TLC5940 using the following pins:

    -------------                                  ---u----
    Ethernet   13|                           OUT1 |1     28| OUT channel 0
    Shield     12|                           OUT2 |2     27|-> GND (VPRG)
               11|                           OUT3 |3     26|-> SIN (pin 7)
    10,underneath|-> BLANK (pin 23)          OUT4 |4     25|-> SCLK (pin 4)
                9|-> XLAT (pin 24)             .  |5     24|-> XLAT (pin 9)
                8|-> to pin 10 on shield       .  |6     23|-> BLANK (pin 10 underneath shield)
                7|-> SIN (pin 26)              .  |7     22|-> GND
                6|                             .  |8     21|-> VCC (+5V)
                5|                             .  |9     20|-> 2K Resistor -> GND
                4|-> SCLK (pin 25)             .  |10    19|-> +5V (DCPRG)
                3|-> GSCLK (pin 18)            .  |11    18|-> GSCLK (pin 3)
                2|                             .  |12    17|-> SOUT
                1|                             .  |13    16|-> XERR
                0|                           OUT14|14    15| OUT channel 15
    -------------                                  --------

Tested with Arduino 1.0.5 on Linux Mint 17 with r14 of the tlc5940arduino library.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.