Introduction: 4x4x4 RGB LED Cube

About: Industrial Designer. Interested in all kind of projects, mainly electronics and object manufacturing.

A while ago, when I first started using Arduino, my first project was a 4x4x4 LED cube, I built it from a Guide I found here in Instructables, I didn't know anything about programming, and little about electronics, yet I was able to build it and make it work, I didn't know how it worked but it did!
That success made me like this page a lot and also made me want to make guides like that one, well documented and properly explained, enabling people to make cool things, at first without them knowing how they work, and from there, from a working piece, start learning and understanding how it works.












note: the last 2 videos are not from my cube, but it works in the same way and gives the same result.

Step 1: Materials

For the most basic cube you will need;
  • 1x Atmega328 (With arduino Optiboot bootloader)
  • 3x TLC5940
  • 4x P-Channel MOSFETs
  • 3x 4K7 Resistors
  • 3x 16 pin Male and Female headers
  • 1x 4 pin Male and female header
  • 1x 28pin IC socket
  • 1x 1000uf 10v capacitor
  • 1x 0.1 uf ceramic capacitor
  • 2x 22pf capacitors
  • 1x 16Mhz crystal oscillator
  • 64x RGB common ANODE LEDs (it is very important that you check your LEDs are common ANODE, or else, the cube won't work!!)
  • a LOT of Solder!

for more advanced functions;
  • 3x 8k2 resistors for optional, low power mode.
  • 3x 3pin male headers for jumper selection of the power mode
  • 3x jumpers for selecting the power usage/brightness setting
  • 2 x 64KB EEPROMs for storing custom animations
  • 1x DIP switch for selecting different modes (random, serial, music responsive, random2, custom animations, etc.)
  • 2x MSGEQ7 chips for audio analyzing and music response.
  • Black paint

Tools;
  • An Arduino to use as a USB to Serial converter for programming
  • An USBTinyISP if your Atmega chip is not pre-Bootloaded
  • A Multimeter for troubleshooting and checking connections
  • Some way of cutting PCBs, I used a Circular Saw, but you can use whatever you have in hand.
  • Diagonal cutters
  • A Sharpie or any kind of marker
  • A Drill/Drillpress
  • A Cutter or Xacto knife

Step 2: Planning

First you'll need to decide the size of your cube, it can be any size you want to, but nothing bigger than what the leads on the LEDs allow, my LEDs had 28mm leads, so I decided my spacing was going to be 25mm between LEDs. THis is usually a good size.

Step 3: Make a Grid

To be able to make all the layers with the same spacing and keed all the LEDs "Snapped to Grid" we need to actually make a grid, for this we will need;

a piece of scrap wood bigger than the size of your cube
a Bit of the right size for your LEDs, its better to measure it with a caliper, but if you don't have one, just trust your maths and the LED Manufacturer's specifications.

my drill press has a table with 2 axis control, it has handles and moves 1mm per revolution, so I just counted 10 turns between each hole, make sure to make your holes at 0 on both Axis (x and Y). Also make sure to set the stopper for the Z axis or you will drill all the way thru your drill press.

I made my grid bigger, 5x5 in case I, in the future want to build another bigger (or smaller) LED cube.

Step 4: Layer by Layer

Once you have your grid ready, you can start making the layer, one by one and testing them as you go, to be able to repair them in case of a faulty LED or solder joint, it's better to take a few extra seconds on each layer than to risk destroying your complete cube trying to replace a faulty LED in the middle. 

I figured out an easy process to build the layers quickly and all the same, just follow my steps;
  1. First off, mark your grid as mine (see pic 1) so you don't get confused about the orientation of the LEDs and as to which pin goes where.
  2. Now place your 16 LEDs (See pic 2), make sure they are in the correct orientation (flat part to the left).
  3. Start bending the leads (the Rightmost lead goes to the bottom left at about 45 degrees) (pic 3).
  4. Keep on with the bending, the 2nd lead from right to left goes to the top right corner at about 45 degrees aswell (pic 4).
  5. Now bend all the longer leads straight to the top, ONLY for the top row (You'll see why) (pic 5).
  6. Proceed to trimming all the remaining standing leads from the TOP ROW ONLY! (pic 7).
  7. Now bend them all to the left (pic 8) they should not touch the neighbor LEDs.
  8. Repeat steps 5 to 7 for the NEXT ROW, soldering each of the leads that reach the top LED's to the leads of those LEDs that go to the top as you go (pics 9 & 10).
  9. Repeat step 8 for the rest of the rows (pic 11).
  10. Trim down all the excess leads (pic 12).
  11. Now proceed to joining the columns, for this, grab a 10 cm long wire and make a small half-loop at the end (pic 13).
  12. pull it so the lead of the LED from the FIRST column id inside the half-loop and solder it down, use a gentle amount of solder (pic 14).
  13. solder the remaining columns to the wire and trim the excess off (pic 15).
  14. add another 3 wires in the same way (pic 16).
Now repeat all steps 3 more times to get all the layers, this might seem a bit tedious, but with some good music, it goes real quick!

Make sure to test your layers as you go.




Step 5: Make a Mess

Now we need to add the wires for the columns, for this we will need 48 wires (pic 3) that are about 12 cm long, then, with the help of a helping hand to hold them in place (see pic 2), start soldering one wire to each lead from every LED.

Step 6: Inserting the Rest of the Layers

Here comes the tricky part, joining the 4 layers, as we have 48 wires sticking out which have to fit in the correct square of the layer grid. To accomplish this we need to be organized, so first we are going to divide all the wires by sections, look at pic 2 for where your wires should be and at pic 3 for where you're aiming to put them.
then insert the next layer, making sure all wires fit into their correct "Sections".
To properly add the layers, we need a way to space them correclty, luckily, 9 vlot batteries are just the right size, so get ahold of 4 of them and place them like in pic 4.

Step 7: Repeat for the Rest of the Layers

just place the remaining 2 layers as you did for the second one. You should now have a complete LED cube, now we can start with the electronics, but, just to be sure, test all the cube one more time, you know, it's best to find out of a dead LED now and not later.

Step 8: The Control Electronics

To begin with the electronic circuitry, we need all the components shown in pic 1 and 2 PCBs the same size or bigger than your cube.

Step 9: Mark and Cut the PCBs

Mark your PCBs just a little bit bigger than the cube (pics 1 & 2) and cut them, I used a circular saw for this but you can use just about anything, even n X-acto knife (pics 3, 4 &5).

Then proceed to sanding all the edges (pic 6).

And finally paint them black with some matte spray paint (pic 7), remember to ONLY paint the top side black, not the copper!

Step 10: Add the Headers to the Top PCB.

get 3 rows of 16 MALE headers and 1 row of 4 MALE headers, we'll be mounting these on one of our PCBs.

First off we need to modify them a bit, pushing the black plastic piece that holds all the pins together right to the very end of the pins, make sure they don't fall off.

Once you've done that, find a proper place to put them in the top board, the exact place is not critical, but try to place them near the edges and make sure they won't obstruct any hole needed by the cube (see next step for more on this) and then push them all the way in and solder ALL the pins from the other side, the 4 pin header will be positioned right at the edge of the board, but don't do that just yet, as we are going to place it in any free space we find left (more on this later).

Step 11: Start Mounting the Cube.

We now need to start mounting the LED cube on the top PCB, I'm using 2 PCBs to keep all the electronics hidden while still having access to them, the boards will be plugged together like an Arduino shield.

To mount the cube we need to make 48 wires fit in their proper holes, to make this easier we are going to trim the leads of the cube as in pic 1 (in an angle) I used some heavy duty stainless steel scissors for this but you can use your typical wire snippers if you don't have access to stronger tools.

start inserting the leads of the cube to the top PCB, the longer leads first, once you have all the leads from the first row in, bend them a bit to prevent them from going back out, then proceed to the next row, I used a pair of modified doctor's thongs (hemostats) (the long, thin ones) to aid me in getting all the leads to the right place, once you finish a row, bend the leads a bit and proceed to the next one, DO NOT SOLDER ANYTHING YET!

Step 12: Finish Mounting the Cube

once you have all your leads in, proceed to soldering the four corner leads to hold the cube in place, BEFORE you do this push the PCB as far in as it will go without damaging anything and make sure all corners are at the same height (pic 1).

Once you have soldered the four corners, check again the height of the corners and, if it's all the same, proceed to soldering all the remaining leads (pic 2).

When you finish soldering all the leads, trim all the excess (pic 3).

Step 13: Connecting the Columns

Now we need to connect all the columns to the nearest pin in one of the 3 MALE headers, it doesn't matter what do you connect where, you can help yourself by dividing the PCB in sectors with a marker, leaving 16 leads for each sector and corresponding header. to connect them all together I used a solder tracing technique (pic 1), I love it as it saves tons of wiring and it is fast, easy and reliable, but it requires a bit of practice, so I would recommend you to do some test traces in one of the pieces of scrap PCB we have left from the cut. also, a PCB with square pads works better with this technique.

Step 14: The Second PCB

Place the 3 FEMALE 16 pin headers on the male ones and then place the second PCB on top of that (pic 1), make sure you align them correctly and proceed to soldering all the pins in place (pic 2).

Step 15: Begin Placing Components

the first thing we need to place in are the 3 TLC5940 PWM ICs, we are going to place one aside each header (pic 2), centered and with the outputs facing the header. (see pic 3 for Pinout of the TLC5940).

After you have placed them, flip the board and solder all the outputs to the headers (pic 4).

Don't worry about the connections just now, we will first place everything and then connect what we can via Solder traces and connet what's left via small wires.

Step 16: Arduinize It.

Now we are going to add the Atmega328 chip, the brains of our cube.

Place it somewhere near the center of the board, use a socket for this one as it is possible that you may need to replace it.

In this step, we'll also add the 3  3-pin headers and 2 resistors for each, the 4k7 ones and the 8k2 ones, place those near the center of each TLC5940 leaving a 1 pin thick gap between the two (pic 1).

Step 17: Adding the Oscilator

Add the crystal oscillator and caps for the Arduino Chip, see pic 2 for the pinout and where you should connect the crystal (the 2 pins that say crystal), then each pin of the crystal goes through a cap to ground.

Step 18: The MOSFETs

find a nice, free space to place your MOSFETs, remember that it needs to be enough to fit them all bent down plus the 4 pin FEMALE header.

If you decided to add some EEPROMs to the cube, now is a good time to add those sockets too, find a small free space and place them there.

Step 19: The Programming Header

VERY IMPORTANT! don't forget to add a six pin right angle male header somewhere near the edge of the board, this will enable us to program our chip with an Arduino or USB to serial adapter and not have to remove the chip every time.

Also, add now the DIP switch, in the same side of the board on where you placed the programming header, in the picture it is tanding up, but I later changed it to a flat position because it is way too high.

Step 20: Connecting the ICs

begin connecting everything together, solder all the TLCs as shown on the picture, joining the 2 pins that go to ground together and the two that go to Vcc, also solder the jumper selector and resistors as shown in pic 1.

From now on, downloading a high resolution version of the schematic will help you a lot, I would print it if I were you.

Step 21: Pull Up's

add some pull up resistos to your MOSFETs, this is to default them to the Off state. they go between the first and last pin of each MOSFET.

Step 22: Getting the Atmega328 Ready

From now on we'll be working with the main chip, so print a copy of this Arduino compatible labels and stick one in your chip to make your life easier and prevent all that nasty de-soldering and head slapping.

Link: http://dl.dropbox.com/u/2295566/BLOG/arduino label/ARDUINO BREADBOARD 28 PIN LABELS.pdf 

Step 23: Connect All the TLCs

Connet all the wires that go between the Arduino chip and the TLCs, remember that all but one wire go to all the chips, the only one that doesn't connect to all of them is the serial one, which goes Arduino->(SIN[TLC1]SOUT)->(SIN[TLC2]SOUT)->(SIN[TLC3]SOUT).

See pic 2 for the wiring.

Step 24: Do What You Can

Now connect what you can directly on the bottom PCB, with solder traces and leave space for adding wires where you couldn't solve a path.

What you need to connect;

your EEPROMs (if you have any).
3 of the 4 pins on the dip switch.
the 2 1000uF caps from Vcc to Gnd
the 2 100nF caps from Vcc to Gnd
the 6 pin programing header, the leftmost pin goes to Arduino's Reset, 2nd pin to Arduino's RX, 3rd to Arduino's TX 4th to VCC and 6th to Gnd, the 5th pin is left unconnected.
Your MOSFETs, the Rightmost pin goes to VCC and the center pin goes to a pin on the 4 pin FEMALE header.
Gnd and VCC to all ICs, try to get at least Gnd done on the bottom side.

Step 25: Do What You Couldn't

Finish up connecting everything on the top side with thin wire wrap, connect each MOSFETs Leftmost pin to a free arduino pin, connect the EEPROMs and connect all the remaining VCC connections, the PWM ICs and the Arduino chip need little current so you can use thin wire, but the MOSFETs need a lot of current so connect them with a thick wire.

Step 26: Troubleshooting.

test that all places which should be connected to VCC are indeed connected, do the same for the Gnd pins, and check that Vcc is not shorted with Gnd.

Step 27: Connecting the Layers.

At this point, you can now add the 4 pin male header to the top PCB and connect, with a wire, each pin to one of the layers, make sure the header aligns with the one on the bottom.

Step 28: The Code.



Congratulations! you have successfully built an RGB LED CUBE! all that's left it to configure the code so it works properly with your cube, so start by plugging the bottom PCB and the Cube PCB together.

The first thing you need to do is find out which pins are your layers connected to, once you've done that, you need to tell the code which pin goes to which layer.

Download the zip file below containing the 2 sketches you'll need and open the main sketch.

Go to the functions tab (pic 2) and then scroll down to the function called "Void CubeUpdate(int layerNoVal)", in there, scroll down untill you see something like this (pic3);

    PORTC |= _BV(PC1);  //layer 4
    PORTC |= _BV(PC2);  //layer 1
    PORTD |= _BV(PD2);  //layer 3
    PORTD |= _BV(PD4);  //layer 2

    Tlc.update();

    PORTC &= ~_BV(PC2);  //layer 1

Change the lines to the Proper ports and port numbers for each layer, see pic1 for the corresponding ports and port numbers for each Arduino pin.

Once you change that, scroll down more and you will find it again, make it look exactly the same as the one you edited above, but instead of layer one pin at the bottom, add the layer 2 pin, repeat this 2 more times for layers 3 & 4.

Finally upload the sketch, your cube should look something like the one on the video, don't worry if it looks all random, we are going to solve this problem on the next step, as long as all the LEDs light up, you are fine.

Step 29: Mapping the LEDs

Now we are going to map the columns to the correct LEDs in the software so it looks like the one on the video from last step.

Upload the Mapping sketch and note down the order in which the LEDs turn on, i would recommend you to make a 4 by 4 table to note down the number in the series in which each LED is lit up, keep in mind that each LED has 3 colors and that you have to note them down aswel, I used different colored pencils for each color, now label all the columns from A to D and the rows aswel.

Now go to the main sketch and, in the Declarations tab, change each LEDs column to the prober number (see pic 2).


Step 30: Enjoy

Congratulations! you now have a working RGB LED cube to show up to your friends, so sit down for a while and enjoy the show.

NOTE: this is not how it should look like, I'll upload the correct video as soon as youtube lets me.

Step 31: (Optional) Make a Nice Base

I machined a nice wooden base for my cube on a friend's CNC, it looks great!





Step 32: Future Updates.

This project is not complete, I still need to;
  • Finish an applet to make it easy for you to make your own animations.
  • Make a set of custom animations in case you don't wanna bother on creating your own.
  • add a Serial mode to be able to control it from a custom app on a computer
  • Make it sound responsive with an MSGEQ7 (the chip didn't arrive on time, I will do it as soon as I get it).

This cube is amazing by itself, but, with the proper code, the possibilities are endless so I encourage you to try and Make your own code, to customize it and make it do whatever you want, this cube makes for a great development platform to learn more advanced coding skills.
Make It Real Challenge

Participated in the
Make It Real Challenge

Arduino Challenge

Participated in the
Arduino Challenge