There are lots of ways to build an LED Cube. Before you start, assess how many LEDs you want to control and how fast you need to refresh the state of your LEDs for dimming and animations. In my case I had a cube of 4x4x4 RGB LEDs which are in total 192 LEDs (64 for every color). I wanted to controle them with an Arduino Nano v3.0 which I had lying around. It turned out that there are not 192 pins on this Arduino, so we need a way to control all 192 LEDs with less pins.
This is when you make your first design decision: Charlieplexing, Shiftregisters or LED-Driver-ICs ?
Charliplexing: This allows you to control a lot of LEDs with a few IOs and some resistor. No other ICs needed. It's an intresting topic and you can read more here (http://en.wikipedia.org/wiki/Charlieplexing). But there are some drawbacks:
- The refresh rate is low and charliplexed RGB Cubes tend to flicker
- High peak current on single LEDs
- Some LEDs can light dimmly when not desired
- Complexity the bigger the matrix the more complex gets the circuit
I wanted a nice and smooth RGB Cube and a low refresh rate and undesired light LEDs were not an option, so I discarded this method. If you got intrested check out this Instructable on how to build an 4x4x4 LED Cube.
Shiftregisters: Shift registers allow you enter data in serial and output data in parallel. The most basic shift register has two inputs and several outputs. One input for data and another one for the clock. If you have a shift register with 8 outputs and want to set the first 4 outputs low and the last 4 outputs high you would do the following:
- Put clock low and data high
- Put clock high for a short amount of time
- Now the first output is set high
- Put the clock high and low three more times
Now the first 4 Outputs are high, we are not done yet. Everytime you put the clock high for a short amount of time the shift register reads the data line. Then it shifts all outputs one up and sets the first output high or low depending on the data line. To get the desired state of our shift register( first 4 low, last 4 high) we need to set the data line low and clock the shift register 4 more times. This will shift the 4 high outputs to the end and enter 4 low outputs at the beginning. There is another example in the pictuer below, it sets the output to 10110111.
Shift registers usually have some more features:
A serial output line. After you put data in 8 times every new clock cycle will push one output state at the end of the shift register out to the serial output line. This allows you to chain multiple shift registers.
Another feature is the output enable line. If you have 8 leds connected to a shift register and you want to put the first 4 low and the last 4 high. Then you need to shift 1111000 to the register. In the process you can observer that the first 4 leds start to light up and then move to the end of the line with every clock cycle. If you don't want to have the shift process you use the output enable line. You pull the output enable line low, and shift your 1111000 to the register. The output will not change until you put the output enable line high again. This way the shift process is not visible.
If you use shift registers for your project you need some transistors after them because they cannot handle the current of several LEDs lit at once. This is why I used Darlington Transistor Arrays. They come as an IC and you don't have to solder a lot of single transistors and pull-up/down resistors to your board. After the transistor array you also need some pre-resistors depending on your LED (because they cannot handle 5V). If you are lazy like me, you buy Resistor Array ICs and put them in sockets. This way you can easyly solder the socket and exchange the resistor array later to adjust the brightness of your LEDs.
If you don't want to use Charlieplexing or shift registers then you
could also use LED-Driver-ICs. They can be controlled like shift
registers and have the darlington transistor array and pre-resistors for
the LED already inside. But where is the fun in that? ^^ If however you
want to use something like this, have a look at the MY9221. They allow
you to control 4 RGB LEDs per IC ( in total 16 LEDs) with up to 60mA per
Conclusion: I went for the shift registers because charlieplexing was not an option and LED-Driver-ICs just seemed to simple ;)