4x4x4 LED Cube
I have always thought LED cubes (also known as hypnocubes) where a really cool idea. The first example I saw out there is a cube of RGB LEDs that is available as a kit (link). Because it comes in pieces it has very detailed assembly instructions that are easily available. Soldering the cube of LEDs looked like the hardest part, but I was also surprised at how many signal lines were required (52 normally for this style of cube). As I have continued to research I've seen that this is often overcome with arrays of some kind of shift register or D flip-flop, but that still felt like a whole lot of overhead. I have always wanted to build my own, but because of how I felt about the solutions I came across I never could get up the motivation to take on the project.
That all changed after I came across the concept of Charlieplexing in a totally unrelated conversation. As soon as I looked into it I saw the potential and knew that this was the electrical solution I needed to build an LED cube that I could be excited about. In essence Charlieplexing is utilizing all three possible states of a microcontroller I/O pin (high, low, and high impedance) to isolate a single LED to turn on while blocking current from flowing through all of the others. Because all pins are used in a bidirectional fashion they can all be used to turn an equal amount of LEDs on and that allows for a significant drop in the required pin count. To put a number on it, N*(N-1) LEDs can be driven with N number of pins. Here's a little table showing the difference in pin requirements:
|Cube Type||Total LEDs||Traditional Pins||Charlieplex Pins|
|1 Color 4x4x4||64||20||9|
|1 Color 8x8x8||512||72||24|
The best resources I found to explain the electrical details of this technique are Wikipedia's pretty good article on it (link) and Maxim Integrated's very helpful application note about Charlieplexing (link). Both do a pretty decent job of explaining the circuit theory behind driving the LEDs, but neither expands very far into the physical placement of the respective LEDs. I know that it takes 9 pins to control 64 LEDs (9 * 8 = 72 LED's max), but that does little to explain which LEDs I should connect to each pin. That is what I'm trying to figure out with this project.
I would like to build a larger 8x8x8 cube eventually, even make it RGB if I can manage it, but for now I am going to build a prototype 4x4x4 single color cube to try and work through most of the complexities before hand. The thing that made the most sense to me was to create something similar to the way Maxim's app note drives the 7-segment display. I connected the LEDs so that each pair of two neighboring verticals is the common cathode of 8 LEDs and the other 8 available signals are what drives the anode of the particular LED that I want to illuminate. Pictured below is how I arranged the cathode verticals. For all images in this post the anode is on the left and cathode is on the right. (Note: pin 1 is shown because that's where it goes off to the MCU, but it is never connected to a cathode because I have 8 fewer LED's than my theoretical maximum with this pin count)
Changing perspectives, looking at only the first layer of LEDs from the right side of the cube the wiring looks like the picture below below. The cathodes of each vertical row are bussed together as described above and there is some creative wire twisting to connect to anodes to their respective pins:
Pin 1: Comes up off the breadboard and connects to the anode of the entire bottom row
Pin 2: A line is taken off of the vertical already connected to pin 2 and it is run to the anode of the second LED on the other 3 verticals.
Pin 3: Starts at the anode of the second LED of the pin 2 vertical, crosses and is connected to the pin 3 vertical, and is then run to the anode of the third LED on the remaining 2 verticals.
Pin 4: A rotated version of pin 3. Starts at the anode of the third LED of the pin 2 vertical, continues to the anode of the third LED of the pin 3 vertical, crosses and is connected to the pin 4 vertical, and is then run to the anode of the top LED on the pin 5 vertical.
Pin 5: A rotated version of pin 2. Comes from the pin 5 vertical and is run to the anode of the top LED on the other 3 verticals.
The wires for pin 4 and 5 cross on the top left but can easily be bent out of each others way or the pin 5 vertical can be extended past the top LED to avoid crossing all together.
The next layer of LEDs is much easier to wire. The verticals are the same as the previous layer and pins 6-9 are connected to all of the anodes on a single row starting from the bottom going to the top.
The next layer of LEDs in, still looking from the right side, is very similar to the previous one. The verticals are now pins 6-9 going from right to left and pins 1-4 are connected to all of the anodes on a single row starting from the bottom going to the top.
The last layer of LEDs, still looking from the right, unsurprisingly looks a whole lot like the first layer. The cathodes are the same as the previous layer and again some creative wire twisting is required:
Pin 5: Connects to the anode of the entire bottom row
Pin 6: Comes off the pin 6 vertical and it is run to the anode of the second LED on the other 3 verticals.
Pin 7: Starts at the anode of the second LED of the pin 6 vertical, crosses and is connected to the pin 7 vertical, and is then run to the anode of the third LED on the remaining 2 verticals.
Pin 8: A rotated version of pin 7. Starts at the anode of the third LED of the pin 6 vertical, continues to the anode of the third LED of the pin 7 vertical, crosses and is connected to the pin 8 vertical, and is then run to the anode of the top LED on the pin 9 vertical.
Pin 9: A rotated version of pin 6. Comes from the pin 9 vertical and is run to the anode of the top LED on the other 3 verticals.
Again wires cross on the top left and they must be bent or run so they do not touch.
I chose to jump signals across inside the cube between layers so that I could use the cathode verticals themselves as signal risers and only connect the MCU to the verticals coming out of the breadboard on the outermost layers. Other options are certainly possible especially if you make a PCB to solder the verticals to, but this is what made sense and what I thought would look best. Here is the cube half assembled:
A jig would have really helped with construction. I will build one next time I go to assemble a cube. With a steady tweezers hand soldering all of the cathodes to the verticals isn't too bad, but the horizontal runs are pretty challenging. Especially the ones with several bends in them. There were a few bumps in the construction phase and a few wires completely removed and redone, but finally the cube was assembled. Once completed I tested each LED and they all worked as intended. The cube construction seems to be done, now it's time to figure out how to drive the thing from a microcontroller.
This method of common cathode verticals could easily be expanded to drive an 8x8x8 cube with 25 pins. That is not as efficient a use because theoretically you should be able to do it with 24 pins (23 * 24 = 552 LEDs max), but I think the extra wiring necessary to make that happen would be arduous to figure out logically, worse to code, and in the end probably block more of the light coming from internal LEDs diminishing the animation visibility. Either way it's a noticeable improvement from the 72 inputs required to drive a traditional 8x8x8 cube with 8 vertical ground planes and 64 verticals each connected to a unique shift register output.
I am documenting this project on Hackaday.io as well. I will post large advancements in the work here, but for smaller, more day to day updates follow the project over on Hackaday.
All drawings made in Fritzing. I should have done that before I soldered the cube...