Introduction: RGB 8x8x8 LED Cube
For those unfamiliar with LED cubes, they are simply a 3-dimensional array of LEDs that make for interesting displays. My project here is not the first RGB LED cube, nor is it the best, but I am documenting my process because while designing this cube I appreciated every resource on 8x8x8 RGB LED cubes I could find. My goals for this project were to create an 8x8x8 multicolor (RGB) LED cube cleanly. That is, with all the electronics contained neatly. Additionally, I wanted to use Arduino code to make it more accessible to others and for ease in upgrading. More on this later though.
The hardest challenge was in making the LED frame straight and square. As with most things, quality depends on how much time you put into it. If I were to redo this project that would be the step I spend the most time trying to get right. Overall the project was rewarding in the end and I would say don't be intimidated by the amount of work needed for design and assembly.
I started this design over a year ago but didn't have the time to work on it for many months unfortunately so I hope I can provide a comprehensive description of the process :) As always I will be happy to answer questions in the comments!
I would also like to point out that along the design and assembly process I learned a lot from some of the other well-documented RGB LED cubes out on the internet. Particularly I recommend taking a look at Kevin Darrah and Nick Schulze. A majority of my work here was based directly on the work of Kevin Darrah on his cube.
Step 1: Skills and Materials Needed
The project requires a lot of soldering. However, none of it is difficult and a beginner solderer would have no problems. I used all through-hole components (although SMD would have been nicer).
Comfort with the Arduino IDE is a bonus but not needed unless you want to change the code.
As for materials, you will need the following:
- Soldering iron + solder
- Hand tools such as tweezers, needlenose pliers, and snips
- Arduino to use as programmer
- 512 RGB LEDs (common anode, diffused)
- Copper wire (I used 24 gauge but thinner would be better)
- 16MHz oscillator
- 25 74HC595 shift registers
- 136 100 ohm resistors
- 64 125 ohm resistors
- 212 1k ohm resistors
- 2 10k ohm resistors
- 2 22pF capacitors
- 0.1 uF capacitor (electrolytic)
- 10 uF capacitor (electrolytic)
- 100 uF capacitor (electrolytic)
- 1000 uF capacitor (electrolytic)
- 25 16-pin IC sockets
- 1 28-pin IC socket
- 2x5 AVR ISP header
- 200 2N3904 transistors
- 8 IRF9540 P-channel MOSFETs (overkill but I had them on-hand)
- Power plug
- Power button
- 5V power supply (1A is sufficient)
Additionally, I had a PCB made for the base of the board to save time and costs on wire management. This also meant I had to make sure my designs were right in the first try. While everything worked great, there are things I would upgrade (such as SMD components or swapping individual parts) if I were to do this again. I also had a base enclosure laser cut to hide the PCB and give it a cleaner look. The files for both of these parts will be included in later steps.
Overall cost for everything above was $80 for all electronics and LEDs, $28 for the PCB, and the base I was able to have laser cut with scrap black acrylic I had sitting around. I priced it out on ponoko as costing $50 but I suggest visiting your local FABlab or makerspace to save costs.
Step 2: How It Works
My LED cube, like nearly every other one online, uses multiplexing to give instructions to each LED. It is very similar to every other LED cube you see on instructables and elsewhere. I am going to leave the description out for this instructable because there are so many other well-written pages on this by now. If you want more information I encourage you to read more from the well documented pages below:
If these don't satisfy your curiosity, post your questions in the comments and I will do my best to answer!
Step 3: Circuit Design
Knowing how you want to board to work brings us to actually designing the circuitry needed to operate the cube. Knowing that we will be using a microcontroller at the brain of the cube, and somehow using connects, we first need to design the circuitry for the anode and cathodes.
The anodes will use the P-channel MOSFETs to switch between layers for the multiplexing. Meanwhile a transistor array will provide power to the cathodes for each LED column. The shift registers (74HC595) will control the transistor array by reading in the serial output of the microcontroller and converting it into a parallel output on the shift register.
Lets break it down even further (skip over if understood):
(going backwards from the LED itself) A series resistor sets the approximate target voltage for the LED (125 ohm for red, 100 ohm for blue and green). This is tied to the collector of a transistor which emits to ground when the base is triggered by an output pin on the shift register with a 1k ohm resistor in series (between pin and transistor). An example with the one line hooked up is shown below.
Each shift register will have 8 outputs so can control 8 pins. Since each LED requires 3 pins (red, green, blue) and since there are 64 columns (8 x 8) we need to have 64 x 3 = 192 pins. This works best if we divide the shift registers in groups of 3 (one set for each color). So now we have 3 columns of 8 shift registers (for a total of 24 shift registers so far).
The anodes control each layer by toggling a transistor (MOSFET below) from another shift register. This time we only need one shift register. The 8 output pins on the shift register control the 8 layers. The values for this shift register is shifted out in the same serial line that gets delivered to each of the other shift registers from the microcontroller. For each of the other layers, you will just copy the circuit below and attach it to the next pin on the shift register.
The microcontroller is an Atmega328P-PU running the arduino bootloader. There are 6 main pins that you have to worry about (apart from the crystal and power lines): pin 1 - Reset, pin 4 - latch, pin 4 - latch, pin 6 - blank, pin 17 - data/MOSI, pin 18 - MISO, pin 19 - clock/SCK.
Pins 1, 7, 8, 17, 18, and 19 can be used to provide an ISP programming header for re-programming the board later if desired (not needed).
The latch, blank, data, and clock pins will be used to control the cube through the shift registers. The LATCH pin on the microcontroller connects to pin 12 of the shift register (74HC595). DATA connects to shift register pin 14. CLOCK connects to shift register pin 11. BLANK connects to shift register pin 13.
The board requires a 5V power supply. To filter noise on the input supply, capacitors are used at few ranges. This part is completely up to you for what you feel is necessary. I used a 0.1uF, 10uF, 100uF, and 1000uF capacitors but this was pseudo-arbitrary.
The full schematic and all EAGLE board files are included in the zip folder on this step. In it you have everything that you would need to have the boards printed off.
Step 4: Software / Code
Originally I started writing code in the Arduino IDE to control the cube but was having difficulties where occasionally the cube would just stop working until you reset it. After a long period of debugging I decided to switch to the fantastic Kevin Darrah's code. His entire webpage was a huge resource along this entire process as I mentioned earlier. I don't think it is appropriate to re-post his code here so I suggest you follow the link to his website and scroll down to the code section. I am using the Arduino code rev 12.
I will go into how I programmed the Atmega328p chip though. First off open the Arduino IDE (assuming you have already downloaded it). We will be following the Arduino guide for burning a bootloader and uploading to a breadboard. We will be using the arduino board as an ISP programmer. First, in the Arduino IDE open up the example ArduinoISP and upload it to your Arduino.
Then, following the diagram below hook up:
- Arduino pin 11 to atmega pin 17
- Arduino pin 12 to atmega pin 18
- Arduino pin 13 to atmega pin 19
- Connect Power and GND lines
- Connect Reset and add a 10k ohm resistor to Vcc
- Add crystal oscillator and 22pF capacitors to atmega side.
Next you will go to tools and select Arduino Duemilanove from the Tools > Board menu. Also, change the programmer to Tools > Programmer > Arduino as ISP. Now you are set to burn the bootloader. Go to Tools > Burn Bootloader. Once completed go ahead and remove the cables from the breadboard.
Next we will program the new atmega328p with the cube code. The easiest way to do this is to take a pair of tweezers and gently pull the microcontroller out of the Arduino you just used to burn the bootloader (dont get these chips mixed up now) and swap in the new microcontroller into the Arduino's IC socket. These two atmega328p chips should be identical now except for what is programmed onto them (they both have the same bootloader though). Open up the cube code and upload it to the Arduino as you would normally. Then gently lift it out again (avoid bending pins as much as possible) and swap the original back in. You now have a fully programmed microcontrller with the cube code on it. Once you place it in the circuitry that we will build later it will be all set to run.
There are many other ways in which to program the microcontroller but this is the only method I am showing here. Feel free to use whatever method you are most comfortable with.
Step 5: Soldering the PCB
This is a pretty straightforward process if you are using a PCB like I did. If you are using other prototyping techniques for the components you will need to deal with the soldering and wiring in your own ways. If you aren't using my PCB (which you can always re-make yourself from a board manufacturer using the files at the end of this step) you may want to skim or skip this step.
The images in this step along with directions are also included as a pdf on this step. Following the pictures in any order, solder the components for each step. Each step's components are highlighted in the corresponding picture. I found it helpful to place components in from topside and then solder from the back (side with less silkscreen). The opposite direction will be used when soldering on the LED columns in a later step.
Step 1: Solder in the 28-pin IC socket for the atmega328 microcontroller
Step 2: Solder in the 16-pin IC socket for the 74HC595’s
Step 3: Solder in two 10kΩ resistors
Step 4: Solder in the 1kΩ resistors
Step 5: Solder in the 125Ω resistors
Step 6: Solder in the 100Ω resistors
Step 7: Solder in the 4 electrolytic capacitors (in any positions)
Step 8: Solder in the 16MHz crystal and the two 22pF capacitors
Step 9: Optionally solder in the 10-pin ISP header
Step 10: Solder in the 8 IRF9640 transistors (flat backing towards center of board)
Step 11: Due to an error in board design you will have to solder the first 2N3904 transistor in backwards. Simply bend the pins mirrored to how you would the other transistors. The silkscreen on the bottom of the PCB identifies how to insert it on the backside, but we want it inserted on the topside so that the board fits in the casing.
Step 12: Solder in the rest of the 2N3904 transistors. The image should do a better job explaining how to insert the transistors than I can explain in words.
Step 6: Casing
Before continuing on to solder the LEDs to the PCB, it was necessary to insert the top layer of the laser cut case. The top panel had holes laser cut exactly where the columns would slide into the PCB holes for soldering so it was easy to align. The case is simple to assemble and can be glued together using a small dab of superglue. The bottom panel will be the very last thing we put onto the cube at the end.
Alongside the box as shown in the pictures above, I cut out a jig to aid in the soldering of LEDs. This was just a backbone acrylic with 8 slots for LEDs to fit into and hold the bracing wires in place while I soldered them in. This is shown in the last 2 pictures above.
Lastly, there are some extra tabs in the laser cutting file that can be used to glue in place the PCB to the top of the box. They aren't needed but can be helpful during soldering.
The svg for the laser cutting file is included on this step.
Step 7: Soldering the LEDs
The video below does a better job showing the procedure for soldering in the LEDs than I will be able to type out. Basically, what you need to do is solder individual columns into the PCB one at a time. To do so:
- Thread 3 copper wires through the holes and solder them to the PCB. I always threaded from the PCB side through the acrylic side.
- Bend the leads as shown for 8 LEDs.
- Pop the LEDs into the jig (in the shown orientation with the common lead (longest) back)
- Slide the jig into position against the copper wires
- Solder each LED in (3 point per LED, 8 LEDs per column)
- Clip excess leads off
- Slide jig up and away from wires and LEDs
- ***Every other sheet of columns (starting with the first sheet) must have the common pins connected with rows of copper wire. see below***
I forgot to include in the video how to connect the common anodes between columns. Hopefully the pictures below help clarify this. In the first picture below you can see the rows that must be added to connect the anodes to each other. Highlighted in red are the rows. Highlighted in yellow are the common anode pins. Note how the pins alternate which direction they point such that you only need half the number of rows (each pair of sheets shares a set of rows instead of each sheet having its own rows to collect anodes). The picture below illustrates this by showing the first two sheets of LEDs sharing one row per layer (layers are horizontal, sheets are vertical). I hope what I am trying to say makes sense. If not, let me know and I will try to re-write this page or video.
Step 8: Final Assembly
Solder in the power jack and power switch. They should screw into the holes that were laser cut into the sides. The diagram shows the proper polarity of the dc power jack and how those wires meet up with the power switch before connecting with the PCB.
Finally, with much pride, pop the bottom acrylic panel onto the back of the case! If you don't glue it, it should be firm enough to stay on but is removable in case you need to get back in to the microcontroller or to fix a soldering mistake.
Step 9: Pictures and Videos
Finally, here are some pictures and videos of the finished project.
For more information and pictures on the assembly process and final product, see my website for this project.