4x4x4 LED Cube - my first Arduino project.

A project by:

Gabriel B. Soares


Date:

Fall 2009


Build Time:

Two Months

group picture

4x4x4 LED Cube

This page describes my very first Arduino project which I started in the summer right after High School and completed during winter break 2009. It was a great project to do to start getting familiar with the Arduino IDE and working with microcontrollers. Prior to this I had never written a line of C and so there were many challenges throughout the process, and ended up spending hours browsing the web trying to learn how everything worked. I also did this before I had taken my Into to Circuits class and so knew very little about BJTs, op-amps, or pretty much anything other than Ohm's Law...

Writing this page 5 years after the completion of the project is interesting since I know so much more and can see a lot of flaws in my original design. If anything it is a testament to the fact that you don't need to know everything in order to complete a project; you just need to know where to look for resources and examples. I ended up learning more by going through this exercise than I did in some of my classes in school (there is something about learning by doing which makes concepts stick a lot more than just being lectured).

I decided to add this project to the site not because I think it is a good design anyone should copy (on the contrary, there are many better and easier ways to get the same result), but because it is the first project that introduced me to the world of microcontrollers, which I now find extraordinarily fascinating.

Multiplexing Challenge:

Like all other projects, this one began by doing a lot of research online on how other people have built their LED cubes. I found everything from 3x3x3 cubes up to 8x8x8. I decided to pick a dimension for the cube which would be challenging enough for me to do using only transistors to control but not too over the top. 4x4x4 (64 total LEDs) seemed like the right number to start with. I soon, however, ran into an issue: I didn't know how to control 64 LEDs using only 14 digital I/O pins (I only had an Arduino UNO)... For a while this problem stomped me, until I found forums that talked about multiplexing large LED arrays using pull-up and pull-down transistor network. With this approach (see first image below) you could control 64 LEDs using 16 pins (you see this approach typically on things like DOT Matrix Displays). The Arduino I was using had 14 digital pins and 5 analog pins (which I could use as digital outputs), so this method could have worked, except that I needed to use a few analog inputs to be able to sample audio signals, and I wanted to have a few spare pins to be able to expand this project in the future and be able to add other components to the board.

For a couple of weeks I worked on figuring out how to reduce the number of needed pins to control all 64 LEDs and ended up with a solution that reduced that number down to 12 pins: 6 I/O to control pull-up network, and the other 6 for the pull-down network (see second and third images below). With my design, I would need to set two pins on the pull-up network high to set an LED column high, and I would need to set two pins on the pull-down network high to connect a row to ground. With this approach I can turn a single LED on at a time by setting four digital pins high.

Once I had an idea of how I was going to control the LEDs I spent the next few days testing out whether this design would work on a breadboard.

group picture group picture group picture group picture
Parts:

Going through a box of old electronic components my dad had, I was able to find a handful of MJE243 npn power transistors, which is what I used for the pull-down network (first photo). I didn't have enough components for the pull-up network, so I just went to RadioShack and bought a bunch of 2N3904 transistors. The LEDs I bought off of eBay as a pack of 100. Other than a few 10kOhm resistors for the gate of each transistor, there weren't too many other parts that I needed to buy that I didn't already have.

After playing around with the LEDs I noticed that the viewing angle was very narrow and I wanted to get a more diffused light. I therefore had to sand down each LED casing in order to get the light to scatter to the sides of the LEDs. You can see in the images below the difference between the original LEDs and after they have been sanded down.

For the cube, I wanted to do the frame out of a light material and ended up going for balsa wood.

group picture group picture group picture group picture
The Cube:

I began the cube by making the balsa frame for the 4 levels. A sharp knife and some super glue is all it took to create a sturdy frame. From there it was a careful process of installing each LED and soldering everything correctly based on the schematics I had drawn. I wish I could give more details as to the procedure that I took to put it all together, but to be honest, I don't even remember. I just remember that it took me A LONG time to put it all together, being very careful not to create a short, making sure I was following the schematic, and carving a small channel on the underside of the balsa so that the wires and resistors would be more or less hidden from view. The copper wire is essentially what holds everything together and surprisingly the whole thing is fairly sturdy.

I also made sure to test all my connections, checked that there weren't any short circuits, and that every LED worked.

group picture group picture group picture group picture group picture group picture group picture group picture
The Base:

The next step in the build was to create a base which would terminate all the row and column connections from the cube, and from which I could run wires back to the Arduino controller. I decided to use a piece of high-density cardboard for the base, on which I drilled holes for the copper wires to go through. On the underside of the board I glued a perfboard onto which I could solder the copper wires and route them to one end of the cube. From here I could run 16 wires (8 for the columns and 8 for the rows if the cube were laid out as an 8-by-8 2-dimensional matrix) out to the pull-up and pull-down transistor network. I used a fair amount of hot glue to prevent the wires from touching and shorting.

Again, at this step I tested all my connections and made sure everything was properly soldered. Once the connections were tested, I added a DB-25 connector I had lying around so that I could have the LED cube be separate from the control board (in case I ever decided on changing the design).

group picture group picture group picture group picture group picture
The Enclosure:

For the enclosure I went into our kitchen and dug up an aluminum storage box that was big enough to hold all of the pieces. The first thing I had to do was insulate the bottom of the container with a piece of flooring underlayment that we had in the house (we had recently installed wooden floors and we had a few extra rolls this stuff). I then cut out the outlines for the male DB-25 plug (through which I would connect to the cube), the Arduino USB connector, and the power connector.

With the enclosure and cube ready, all that was left to do was to build the pull-up and pull-down transistor networks, solder all the connections, and start playing with the Arduino code.

group picture group picture group picture group picture group picture group picture group picture
The Transistor Network:

With another perfboard I started building the pull-up and pull-down transistor networks (12 npn transistors for each network), and testing at every step to make sure that I was getting the same types of characteristics as when I tested on the breadboard. I then connected the output of these networks to the DB-25 connector making sure that each wire matched the corresponding row or column on the cube. I went slowly on this part because I needed to make sure that I wouldn't burn out one of the LEDs by sourcing too much current (the design of the cube meant that it would not be easy to replace a burnt-out LED). So I tested with spare LEDs first, then made continuity tests, and only once I was happy with all the results did I connect everything together and started testing the whole setup.

group picture group picture group picture group picture
Graphic Equalizer:

Once I had everything connected, tested, and working I decided that I wanted to add some audio processing capability to the project and be able to use the cube as a graphic equalizer. At this point in time, I had not taken any DSP classes, and so I had no concept of FFTs or how to get frequency components from an audio signal. That's where the MSGEQ7 came in: it's an IC (8-pin DIP package) that takes an audio signal as input and outputs the amplitude of 7 frequency bands (63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and 16kHz). Using this chip made it very easy for me to add a 3.5mm jack and a few passive components, and be able to use the data from the IC to use the cube as a graphic equalizer (there are a ton of tutorials online which show how to use this chip).

Results:

Follow this link to see a video of how the cube behaves as I sweep from low to high frequencies...

For some reason, my 2009 self didn't realize that shooting videos vertically was a horrible idea, but you can at least see the results of the project in the following video...

Given that this was my very first project done with an Arduino, I would have to say that I am quite pleased with how everything turned out. If I were to build this all over again, I would not build a pull-up and pull-down transistor network, I would instead just use shift registers and control the whole thing through a serial interface. I would also probably expand to using RGB LEDs (which would increase the complexity of the system, but allow for much nicer effects).

By going through this exercise I learned about the basics of BJTs, became familiar with the Arduino IDE, learned about multiplexing techniques, and most importantly, began developing an interest for the world of microcontrollers.