# Looking to create 36 channels of PWM control for LED sculpture

I'm a sculptor, not an EE, but I'm trying to incorporate controllable LEDs into a piece that I'm working on, and I could use some advice figuring out a practical approach. I'd like to be able to control 12 separate channels (the piece is a dodecahedron) of RGB strips, and that means I'll need 36 PWM outs, which is more than I have access to on an Arduino. As far as I can tell I'll need a shield, something like TLC5940 Breakout - though that only gives me 16 PWMs so I'd need to daisy chain three of them, which I know can be done, but I'd like to know what issues might result. Something like Brilldea LED Painter might also be a solution, but I'm relatively pressed for time, so something pre-assembled would be a nice perk.

I'm new to this, so I'm not sure of the accuracy of what I just said, but hopefully some of you can fill me in on what might be a reasonable approach. Thanks for your help.

• But you really need to drive all the strips and all the colors independently? If you find a rule that decreases the number of variables, you can make it simpler. – clabacchio Feb 22 '12 at 8:02
• It's an art project, so I don't "need" to do anything. But yeah, in an ideal scenario (and it sounds like it's a realistic scenario) I'll be able to drive each strip independently in order to create the effects that I want. Scaling back will restrict the visualizations I can create. – the_koo Feb 23 '12 at 8:25

In my opinion, your approach in using this breakout board by sparkfun sounds really good :)

The big advantages are that this board provides 16 PWM channels that are programmable via a daisy chainable serial interface, all led inputs are easily accessible and easy to keep track of.

Also - you probably know already, if you plan on using Arduino, a library that will help you manipulate the driver already exists.

In case you didn't, you should also check out their project home

Since you said that you are pressed I think this solution would allow you to work fast and easy in order to get those leds up and running the way you want them to - Good luck with your project! :)

• The LED painter looks perfect for his project. – joeforker Feb 22 '12 at 15:38
• Thanks, I like the look of the TLC5940. In fact, the LED painter actually uses three of them (NT, as opposed to RHB on the breakout). As best I can tell, the painter is dividing the colors across the three drivers, whereas with the breakout the channels wouldn't be divided. Can you tell me if there are disadvantages to either approach, and more importantly, which would be harder to program for? Thanks for all the help! – the_koo Feb 23 '12 at 8:15
• (part1): Yes you are correct, the LED painter splits RGB among the three TLCs, but there is no reason you can't use the breakout boards in the same way, in fact, I think this is a really good idea. Reagarding the breakout board you probably already know that in the pics the 0,1,2 ... 15 connectors are the way they are in order to accommodate RC servo connections. One GROUND, one BATTERY (+5V) and one PWM output. When wiring, you will only need to use the PWM output, and of course the GROUND from one board (provided that GROUND is common for all 3 boards). – Dan Feb 23 '12 at 12:18
• (part2): About advantages and disadvantages ... I think that spliting the colors would allow you to work much more oraganized and that's a really good thing, from both software and hardware point of view, other than that, I can't think about something to say like "this is much better because..." Finnaly, spliting RGB over the 3 TLCs, using the breakout boards looks like the way to go from my point of view. LED painter is also great, but they're out of stock :) – Dan Feb 23 '12 at 12:18
• The main reason to drive each color on its own TLC5940 is so you can drive each color with a different amount of current (all the constant-current sinks on a single TLC5940 will sink the same amount of current). It is not more difficult to program one way or the other. – joeforker Feb 23 '12 at 14:25

There is a fancy Arduino library for doing PWM through shift registers, called ShiftPWM. It was developed more or less specifically for what you are wanting to do (control lots of RGB LEDs with an Arduino). I saw this on Hack-a-Day several months ago. It looks very cool and boasts the potential to control 768 LEDs (or 256 RGB LEDs) at 5-bits (i.e. 32 brightness levels) per color channel (i.e. >32000 possible colors). I'm looking forward to using this library at some point myself. And it's only going to take up three pins on your Arduino - for serial, clock, and latch to the initial shift register (in the chain). This library is meant to drive something like the 74HC595 shift register, which is hell of a lot cheaper than the TLC5940.

• The TLC5940 is not "a hell of a lot more expensive" than the 3 74HC595 shift registers (purchased in small quantities) that you would need to replace it, and the TLC5940 uses the same number of pins and takes a lot of timing constraints out of the microcontroller. – joeforker Feb 22 '12 at 21:52
• To get 256 brightness levels, does one really need to feed the shifters 256 times per frame? Some other approaches would seem to allow one to get by with a lot less. – supercat Feb 22 '12 at 23:40
• I like this idea, but I have enough financial support that cost of the TLC5940 shouldn't be much of an issue. I'd also like to have 256 levels as I'm writing a program that will convert motion (it'll be converting data from a Kinect) into a color, so having a bigger range makes the algorithm more interesting. Thanks though. Might still be useful. – the_koo Feb 23 '12 at 3:36

You don't need PWM. Any output (IO) pin on a microcontroller will work.

A PWM lets you set a duty cycle (on/off time) then repeats this indefinitely, which results in a variable brightness. IO pins can be turned on and off based on a timer to achieve the same result. The PWM is technically more precise and can change faster than the IO pins, but the human eye can't see the difference. The result will be exactly the same.

So you need a microcontroller with 36 IO pins.

• If you're trying to avoid external hardware, it would also have to be able to sink enough current to drive those 36 LEDs... – joeforker Feb 22 '12 at 15:37
• Yup, 100 Hz or so would be plenty fast to produce no visible flickering. The clock on an Arduino runs at 8,000,000 Hz, so you can do this in software. – Kevin Vermeer Feb 22 '12 at 21:08
• That's useful to know, but my Arduino still doesn't have 36 output pins, so I still need to figure the best way to string together all those pins. Thank you though! – the_koo Feb 23 '12 at 8:21
• @the_koo: Arduinos are pretty small -- perhaps you could find room to squeeze in 3 or 4 Arduinos, each one controlling a few of the RGB strips. Or perhaps upgrade to a Arduino Mega 2560 which has 54 output pins. – davidcary Feb 24 '12 at 0:02

(Apologies for advertisy post but couldn't see any way to contact user directly) I manufacture a 48 channel DMX dimmer designed to drive LED strips, which may give you an of-the-shelf solution. email me via whitewing.co.uk

Another option you may want to consider is:

I have no connections to this company, I have just used the product.

I would suggest using controlled-current shift registers and allowing the current-control wire to be CPU controlled (possibly by including one or more non-current-controlled shifters in the chain and having them control resistor dividers). If you want 6-bit brightness control, and a maximum reload speed of 10 times the PWM rate (e.g. a max of one reload per millisecond to achieve a 100Hz frame rate), I would suggest that the six bits of each PWM value be divided among six shift buffers (so bit N of buffer B would be bit B of LED N's brightness). Then every 10 cycles, the reload pattern would be:

Cycle 0: Load all shifters with buffer 5, full current
Cycle 1-3: Keep same data in shifters
Cycle 4: Load all shifters with buffer 4, full current
Cycle 5: Keep same data in shifters
Cycle 6: Load all shifters with buffer 3, full current
Cycle 7: Load all shifters with buffer 2, half current
Cycle 8: Load all shifters with buffer 1, quarter current
Cycle 9: Load all shifters with buffer 0, 1/8 current


This approach would allow the average current to be set from 1/80 of the maximum peak to 63/80 of the maximum peak, in units of 1/80, using a reload rate that's only 10x the frame rate. If one wants 256 brightness levels, one could add reloads at 1/16 and 1/32 current (12 reloads per frame instead of 10). That would allow the average current to be set from 1/384 to 255/384 with only a modest increase in reload rate.

This http://www.adafruit.com/products/306 could be an option. It has 32 RGB addressable lEDS per strip and you can cut the strip (yeap these a tutorial for that) so you place them

• Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Kevin Vermeer Feb 22 '12 at 21:09
• I'm not trying to address individual LEDs on one strip. I need to address a whole bunch of separate strips. – the_koo Feb 23 '12 at 8:16