# How should I light up all the LEDs?

I am working on a 4x4x4 LED cube. I have connected all the negative terminals of LEDs in a horizontal layer to each other, and am using one Arduino pin per layer. I have connected all the LED positive terminals of a vertical column together and am controlling each column via a pin.

So, 16 pins used for columns and 4 pins used for horizontal layers. The pins are directly powering and sinking the LEDs.

From my calculations, I can turn on atmost 16 LEDs at one time before reaching current limits. So, if I want to light up all the layers simultaneously, without burning the board, how should I go about it ?

• @MarkBooth Directly sinking in an I/O pin. Apr 18, 2013 at 15:13

Generally speaking these led cubes use persistence of vision and multiplexing to minimise the number of wires and digital IO pins for a given size of cube, but in your case you can also use it to reduce the overall current drawn by the cube. Instead of just turning a LED on or off, you would flash the led many times per second to provide an apparently continuous brightness but at a much lower current draw.

For instance, if you can continuously power 16 LEDs but need to power 64 LEDs then you can do so if you have a duty cycle of 25%. Each LED will be powered on for a quarter of the time and powered off for three quarters of the time, so it will be 1/4 of the brightness of the continuously powered LED but also consume only 1/4 of the power.

If you can cycle between the 4 planes every every 5ms (50Hz) then depending on how bright the cube LEDs are people looking directly at the cube probably won't notice the flickering, but anyone looking elsewhere will probably notice the flickering out of the corner of their eye. At 2ms (125Hz) few people would notice the flickering, even out of the corner of their eye.

Best way to do so is multiplexing.

That's the way your Monitors / Displays (cellphone, laptop and so on) work. I would also recommend shift-registers (as I wrote in this topic)

Hope that helps!

The Texas Instruments TLC5940 is another way to easily drive LEDs from the arduino. You can apparently daisy chain up to 40 of them together. There's so much good information on the arduino playground page. Please go check it out.

Here's one example from an arduino forum user named saeveritt that illustrates an idea of how the wiring diagram would look. Do follow the links to learn about how to power this many LEDs using this technique.

I would think that with an appropriate number of transistors you could switch things without having to sink all the LED current through an Arduino pin.

You don't indicate your power source, but I would do it powering the LEDs direct (not through the Arduino) and using the Arduio to flip transistor switches.

• Can you explain this more on how to do this... maybe a link or example schematic? Apr 18, 2013 at 22:23
• @annonomus person - Let's assume a 5v source. I think instead of "5v > Arduino pin > bunch of LED's > ground" you would do "5V > Arduino pin > NPN transistor base" and "5v > transistor collector > transistor emitter > bunch of LED's > ground". Write "high" to the NPN base from the Arduino to flip the transistor and turn on LED's without sinking the current through the Arduino pin. Apr 19, 2013 at 17:49
• I know that, but I mean what transistor would you use? Just any that would meet the current? I mean, how do you calculate how much voltage and saturation you need to power it, etc? Apr 19, 2013 at 20:39
• I think those in the know would use a fancy MOSFET. I would try it with a 2N3904 because I have a bunch of them on hand. Apr 21, 2013 at 5:15