Our lates videos on YouTube



Summary

Intro

In this tutorial I will show you how to build your own 3D LED CUBE.

There're tree parts in a cube - the LED martix, the controller and the case(you don't really need it to compleate this project). So the tutorial is divided into three parts, the LED MATRIX, the CONTROLLER and the BOX.

The martix is relatively easy to construct, I will show you howto to do it step-by-step with enough explanation so anyone can do it himself.

The controller is a bit of a problem, especially for the ones with no knowladge in programming and electronics, but I'll do my best to describe the idea, and give you some schematics, futhermore if you cannot build it your self you can order it from our on-line store.

The box is just my idea for a box, you can build whatever box you like and this part is really just some hints on how to do it.

So lets start with the matrix


THE LED MATRIX

Step 1 - Prepare your LEDs

step 1

The first thing we need is some RGB LEDs. Depending on the size of the cube we are going to make we will need 64 leds for 4x4x4 cube or 125 leds fo 5x5x5.

Now some info about the LEDs. We need 5mm or 10mm RGB(Red Green Blue) LEDs with four terminals, common anode type. Note that there is another type of RGB LEDs, that are sometimes refered as slow/fast flashing RGB LEDs and they are not suitable for our purpose. The right diodes are RGB Manual controlled LED with 4 terminals, so if they have 4 legs they are OK. The other very very important thing about our leds is that they must be a "common anode" type. That means that the common terminal of the diode is the anode (the positive terminal).

So where to get these common anode, 4 terminals RGB LEDs? Well I prefer eBay but you can get it from whatever supplier you like. Just remember, common anode and 4 terminals.

Ok, so now we have our leds, so what's next? We have to prepare them. We do it in 2 steps.

Step 1 - check what type of lens do your leds have. If it is the "water clear" one, you'll need to diffuse them, because they will emit light, but the led bulb itself will not look bright and colorfull. To diffuse them we use sand paper (I recomend it, eventhough it is a slow and tedious) or you can put them some hot glue on, or paint them with a nail polish with perl color. If you have spent some extra bucks on the diffused type, you get away with this step.

Step 2 - bending the legs. In order to solder the led matrix easily, we must pre-bend our didodes' leds. It is shown in the picture how to do it. To bend them I'm using a pair of tweezers. Be carefull with the legs order. Look at the picture, on the top left one, you see two leds, the top one is not bended yet and the bottom one is ready. As you see the legs have different lengths. The longest is the anode, it is one of the inner pins. The one pin on its side is usually the red channel, on the other side of the anode are the green and the blue. So you bend the red pin by 90', then the blue and the green pins also by 90' but in the opposite direction, 3-4mm distance between the green and the blue pins is ok, the last is the anode, you bend it in by 90' perpendicular to the othe 3, it doesnt really matters whitch side you choose, but bend all the leds just the same, this is very important.

Sanding the leds takes me about two minutes per led and bending them about one minute, so a total of 3 minutes per led.

BONUS: Once you have sanded your leds and bent them, I prefer to cover their pins in solder, it is for eviromental protection, as the pins are galvanized, but when bent the protective layer is cracked and in time they become rusty, also if you use acid flux to solder them it gets even worse. So solder them, then rinse them with hot running water, and dry them with a hair dryer.


Step 2 - Prepare your helping tools

step 2

So some things that will help you alot. As you see in the picture there are three peaces of 3-4mm MDF. The top two are a bit bigger than I needed, so it's not a problem if they are smaller ones, in the next step you'll find out how to use them. The bottom one is just a peace of wood, plywood, MDF ot whatever you may find fit. I have drilled 25 holes in it, 5mm each, equally spaced at 4cm from eachother or about 1 5/8 inches. We will put our bent leds in them.


Step 3 - Soldering the leds in rows

Preparations

Before we continue with the soldering, we'll need to prepare some stright wire, that we solder our leds to. For a 5x5x5 cube, we need 25*3 + 5*3 = 140 peaces of stright wire. The first 125 pcs. must be atleast 20cm, but I prefer to be 25cm to have enough space for mistakes.

Stightening a wire is a bit of a quest if you don't know how to do it. So here is how I do it.

I get my wire from the local hardware store. It is 75 meters, 0.75mm galvanized steel wire on a roll. So I must cut it into peaces first, approximately 25cm each (it is not important to be very precise here). Next we need a vice and a pair of pliers (a bigger ones). Now we put one end of the wire in the vice, about 1/4 inch or 5-6mm and fasten it. Now pick the other end with the pliers, and pull it almost horizontally with yor hand, as if you are trying to break the wire. (this type of wire, 0.75mm glavanized steel is soft and not very strong, you can break it really easy if you want to.) There are tree type of results of your pullings - the wire breaks at the vice end, the wire breaks at the pliers end, the wire does not break. The first - breaking the wire at the vice is not really welcomed, you'll get a stright but not quite stright wire. Breaking the wire at the pliers end is OK, but you will result with a stright wire with some strange curvings at the pliers end (if your wire is long enough, you can live with it quite happily). Mastering this exercise requires that you don't break the wire, but it becomes straight from end to end. How? The secret is to feel the moment. When you pull the wire, there is a moment, that the wire stretches like rubber. Do some test, feel the moment, don't stop pulling the wire imediately after you have feel the stretching, just keep pulling for a little bit more, just a bit, then stop - you have your wire straight. If you continue to pull you'll break it. So try it and you'll feel it.

Soldering the bottom wires

step 3

Now as we have our wires straighten, we can continue with the soldering.

Look at the picture above. Take two peaces of wire, and put them on the top helper planes. Now take a LED and put it in the hole, as that you press the straight wires with the led, put the other four leds the same way. (IMPORTANT: when makeing the jig with the holes, try them with a led, the led must go in the hole with a bit of a force, not to be loose. This is importat because it will "lock" the leds and the two wires, so that they don't misalign while you are soldering them.) Once the setup is "locked" soldering is not a problem at all.

Soldering the top wire

step 4

The bottom two wires are easier to solder, for the top one we'll need to be a bit more precise, as it is not locked with the others. We place another wire just over the bottom one, and solder it to the remaining pins. First solder the fist and the fifth led, and then continue with the inner ones.

The final rows must look like this

step 5

The final rows of leds must look something like the ones on the pictures above. All leds must be aligned the same way, and straight wires soldered to their pins. All red pins must be soldered to one stright wire, all green to another and the blue ones must be soldered to a third wire. So each straight wire is red, green or blue channel for its row (5 leds).


Step 4 - Soldering the rows into planes

step 6

For this step we'll need another jig. This one must be of a soft and strong material. I'm using a thermo-insulation sheet of XPS (extruded polystyrene), you can use a EPS (expanded polystyrene) but I like the XPS more for this task. Mine is 8cm for roof insulation, but the regular 4cm is better as it doesn't have this channels on it and is smoother. The purpose of this blue thing is to pin our leds in it, so they stand still while we are soldering them. Take a piece of wire (one of the straight wires will be ok) and pin it in the blue to make 25 holes, 4cm from each other, into the shape of a squre, as it is shown in the picture. Now take your led rows and put them in the holes, just like in the photo above.

step 7

As we have aligned our rows in a plane, we must solder the only pins left of the leds to a common wires. Put a straight wire as shown on the picture above, our wire is about 25cm long, so leave 2-3cm of wire extending over the top side of the leds. The rest 7-8cm leave on the bottom side. When soldering the wires, be carefull to leave exactly 4cm(+-1mm is not of a big trouble) between each wire as they must fit the base of your cube.


Step 5 - Trimming the pins

step 8

When you are ready with the soldering you must have 5 planes with 25 leds in each. Now we must trim the pins that extend over the wires.

step 9

Your final result must look something like this. Five such planes of 25 leds in each, trimmed and waiting to be soldered on your base.

After you are ready, I recommend to rinse the nets in hot water and dry them carefully with a hair dryer.

BONUS: One thing I do is sealing the bottom of the leds with pearl color nail polish, just turn the nets up-side down, put them in the first jig, and put a drop of nail polish on the base of their bulbs, to seal the bottoms, and protect them from corrosion. Left them dry over the night, and in the morning they are ready.


THE CONTROLLER

The base

base pcb

The base is a one sided PCB, it is really simple one, 25 holes for the anode wires, and another 15 holes (3 for each horizontal plane). And pads for a 40 pin connector, this is a SMD type of a connector, so that you don't have ugly soldering on the visible side of the PCB. Some bridges must be done with a thin wire, from the visible side, but if done carefully it might look as a feature.

The controller

pcb side 1 pcb side 2

The design of the controller is not very simple, my first one was a through-hole, one-side design, for my 4x4x4 project, but it has some flaws and I went to a new one, although the main concept is the same.

How a led cude works?

Well, it uses a POV effect. Infact the cube does not emits continuous light, but it flickers very fast, so fast that your brain thinks it is not flickering at all. This is done for one very good reason. If the cube was constucted to not flicker at all (and this setup is possible) for the wireing of the leds we will need 125 x 4 pins and this is 500 pins, that we control simultaniously. Of course, it is not practical nor efficient to use it, so we get away with just 40 pins (25 for the anodes and 5x3 for the 3 channels - RGB). So what we really do is light the red channel for a fraction of the second, then switch to the green and finally to the blue. We can switch the channels some hundred times per second so what you see at the end looks like a perfect complex color to you.

It is good to be known that any color can be generated using just three colors - red, green, blue. For example, the yellow is a mixture of green and red, while the purple is composed of blue and red light. Mixing the three light in different quantities give us almost all colors available to the human eye.

So we need something that can handle 40 channels and control them simultaniously. Although there are such processors, using them in this way is not a great idea. First we need 40 channels capable of sourcing enough current to the cube to shine. And second, we need 40 channels. So we need something powerfull enough to do the job and with enough pins, so that we can letf the processor to be just the brain behind our controller.

There're some designs out there, mainly using a common cathode leds, but my design is different, as it uses common anode leds. So we need 25 pins sourcing current, and 15 pins sinking current. For this task we'll use some shift registers and some transistor arrays. For the souring we'll use the 74HC595 8-stage serial shift register, and for the sinking the ULN2003 7-transistor array. The 74HC595 is capable of sourcing 35mA per channel, as each of our channels(anodes) is suppling only one led with current (at a time), this is enough for a led (20mA typical consumation). The sinking is another type of story, as we have to sink the current from max to 25 leds(one plane), so 25x20mA = 500mA to be sunk per channel. The ULN2003 is capable of sinking 500mA per channel, so it is also OK for our project.

Now something about the processor. It is a Microchip PIC microcontroller, I have choosen the dsPIC33FJ256GP506 from the dsPIC33 familly. It is a High-Performance, 16-Bit Digital Signal Controller - cheap, fast with enough pins and RAM. It is 3,3V operational, and maximum of 5mA current sourcing/sinking per pin, so as this current is not enough for our leds to be powered directly, we will use them to interface the 74HC595 shift registers that will power and control the channels.

For those that are not familliar with the term shift register, here is some more info Shift register (wiki). So what these shift registers are good for? Well, ours are of the SIPO type, that means you control them with a serial signal, and they output parallel signal. Parallel is what we need to control many channels at once. The shift registers are really simple, once you set them up, with the serial signal, they hold the parallel output until you change the setup again.

74hc595

(fig.1) So let's look at the image on the left. This is a simplified schematics of a 74HC595 shift-register, controlling 8 leds. The setup is very simple. We have tied all leds anodes (positive terminals) to the hot rail, and each cathode to the shift-register's terminals. (I have skipped the limiting resistors for the diodes, for simplisity). So all we have to do to light a diode is to create potential difference at its terminals, so that the current can flow. As you see in the picture, only the leds that have zero(0) at their cathode terminals are lit. The top 8 pins of the 74HC595 are the parallel output, and we have set it up using the 4 pins on its bottom side, using our MCU. In fact we can program a shift register only by 2 pins, but the other 2 make it more flexible and usefull. So the conclusion is that we can control 8 lines by using just 4 pins. But the best is that with some 74HC595s we can control as many lines as we can using just these 4 pins.

74hc595 x 2

(fig.2) On the left there is a example of adding another 74HC595 to the first one. As you see we use the already used pins on the MCU. So what this setup is different from the first. As shown we have tied the CLOCK and CLEAR signals to each other, so we control the shifts as one. The thing that you must pay attention is that the MCU is suppling DATA only to the right shift register, and the left one takes its DATA from the OUTPUT from the first. This OUTPUT pin infact is the 9th channel of the register. So the 9th channel of the first is the 1st channel of the second, and voila - we have 16 channels controlled with just 4 pins.

row npn

(fig.3) Now let's take a look at just 5 leds connected the same way as above, but now we have added another control. We can switch the power to all of them on or off, using a NPN transistor. We have our 74HC595 set up and it is outputing the pattern we want, but now we can switch on or off the leds by turning the NPN on or off. On the picture it is on, we have (1) to the BASE, so the current flows from the leds to the ground. When we put (0) on the base, the NPN is blocked and no current flows, so the LEDs are all off. If we put back (1) to the base, the LEDs light up in the same pattern as before. So the NPN is just a power switch. As maybe you have already notice, there is a 2K2 resistor tied to the (+) and to the catodes of the leds. This is the so called pull-up resistor. It is there to holds the line hi, if the NPN is blocked (the key is open). Holding the line hi, make us sure no current will flow when the key is open. In fact, the 2K2 is so big for this voltage +5V that only 0,2mA of current will flow from source to ground when the key is closed, and this 0,2mA is not a big deal, anyway you can choose whatever value you'd like for the pull-up, it might be as well as 10K or more and the leak would be just 0,05mA.

Now we have all the basic knowladge to continue with the big picture. We have 25 channels to control the anodes of the leds (25 leds = one horizontal plane). We have 3 color channels for each plane, this is 3(channels) x 5(planes) = 15 pins. We control the 25 anodes directly from 3 shift-registers connected in series (see fig.2). And we need 15 pins to control the RGB channels, we will use 2 shift-registers that feed two ULN2003 trasistor arrays. We will use these 15 color channel to select whitch one is active at the moment, and we will cycle them just like : plane(1) - chanel(red); 1-G; 1-B; 2-R; 2-G; 2-B; 3-R; 3-G; 3-B; 4-R; 4-G; 4-B; 5-R; 5-G; 5-B; Once the plane is selected we load the 25 channels of the anodes with the pattern we want, cycle the color channel again, again loading the appropriate pattern and so on...

big scheme

Here is the big scheme, it is only for 25 leds, but it is really no need to do it for the all 125, as you have the 3D led matrix contstuction and it is the solution. For those that still can't imagine how everything is connected, here is a 3D scheme, I hope it helps.

full scheme