Hi Everyone, So I have some programming experience, but I do not have alot of hardware programming experience. Currently I am trying to figure out this PWM LED driver (TLC5940NT, http://pdf1.alldatasheet.com/datasheet-pdf/view/146159/TI/TLC5940NT.html) that uses a SPI interface. I have some starting code (shown below) which is my vague idea to setup all the pins for talking to the chip (I am using the Mega2560). Although, I do not know how I can send the transmission in one big data block.

http://jwtanner.com/led_wheel/led_controller.html I was looking at this guy's project and it kind of helped, but for simplicity I am just trying to find out how to work it on the basic level, so I have 2 LEDs one hooked up to pin 14, the other to pin 1 on the chip. I want to send 1000 just to those two pins, so I was trying figure out how to do it in one line.

Also I have been doing some reading about SPI, and it seems every chip has a slave select pin, but I cannot figure out for the life of me which is the SS pin on this chip (pg 7 datasheet).

Any help would be greatly appreciated!


#define MOSI 51//Master Out Slave In
#define MISO 50//Master In Slave Out
#define SPICLOCK 52//clk
#define LATCH 49//latch

setup void() {

loop void() {

  shiftOut(MOSI, SPICLOCK, MSBFIRST,0x08);
  //I'm pretty sure there is a more efficient way of doing this, just giving an idea on what I'm trying to accomplish.


I'm not quite sure what you're trying to tell me just by pasting the pin mapping of the Mega. Have you looked at my code? At the begining I defined the pins that are supposed to be used for MISO,MOSI,and CLK. I was wondering if I assigned them correctly with the code I wrote, or if they had to be defined a different way.

Thanks David

You asked which is the SS pin, and by 'this chip' I assumed you meant the atmeg2560; so I referred you to the pin mapping chart. But maybe you meant the TLC5940? The TLC5940 isn't really an SPI chip (it has no SS pin and doesn't use the standard SPI pin designatons), although you can drive it from an Arduino using SPI.

The shiftOut function doesn't use the atmega hardware SPI, it's a sort of software SPI. You can use any output pins you like with shiftOut. Using hardware SPI is faster but can only be used with the hardware SPI pins, and the SS pin must be configured as an output too (you could use it as the Latch pin). If you want to use hardware SPI then try the SPI library. However, I suggest you get shiftOut working first.

Your code looks OK to me except that for a single TLC5940, you need to send either 96 bits or 192 bits to it before toggling the latch pin. So call shiftOut 12 or 24 times (e.g. in a loop), then toggle the latch pin.

There is a playground page on the TLC5940 at http://www.arduino.cc/playground/Learning/TLC5940.