Introduction: 4X4X4 LED Cube W/ Arduino Uno


As someone who is very new to digital electronics this LED cube was fun to make, challenging and a great lesson in soldering. If you have some patience (64 LED's to solder!) and steady hands, this project will be well worth it in the end!

Step 1: Materials & Tools

Materials:
-64 LED's ( I used 3mm ones on my cube)
-16 resistors ( I used 330ohm)
-solid uninsulated wire to connect the rows of LED's together
-Arduino Uno 
-Prototype Shield V.5
-2 six pin headers and 2 eight pin headers
-20 pieces of stranded wire (Using multicolored ones will help keep your wiring organized)
-1 stripboard or prototyping board with copper leads (The ones without leads are fine, the copper leads just save you a step)
-A case to hold your cube( I used this one for mine http://www.amazon.com/gp/product/B007POB8PK/ref=oh_details_o01_s00_i01?ie=UTF8&psc=1)
-Optional: A plastic covering to house your cube( I ordered 5 plastic squares with a two way mirror film from TAP Plastics to make my cover. The mirror element gives the illusion of infinity lights)


Tools:
-soldering iron
-solder
-drill with a 3mm bit( or any other size depending on your LED)
-ruler
-masking tape
-pliers 

Step 2: Creating a LED Template

In order to create a LED template you will need to measure out where to place all your LED's.

First, cover the top of your surface with masking tape in order to keep it free from scratches and solder that may drop on it later.

After make 16 marks to represent where each LED will go. Then make an extra 4 marks at one end of the grid. These extra marks will be where we connect the common cathodes of each layer to the Arduino. (Picture 1) A good thing to remember when marking your spots is that the cathode(shorter and negatively charged leg) of each LED will need to overlap with the other. That means the spacing between each LED needs to account for that. (Picture 2) For example, if each cathode leg measures to about 23mm when bent I would subtract about 1mm from that and space each of my holes out by 22mm so I would have a 1mm overlap. 

After marking where to place your LED's grab your drill and fit it with the same size bit as your LED bulb size. I used a 3mm drill bit on mine since my LED's were 3mm. After drilling your 16 holes with that bit switch to a smaller bit for the last 4 holes at the end of the grid. For mine I used a 1.5mm drill bit. 

Step 3: LED Layers

Now to solder all your LED's together!

First, make sure all your LED's are working! Yes, it might take a while to test out 64 LED's but it is definitely worth it. You don't want to find out you have a dead LED in the middle of this project.

Step 1)After testing out your LED's you will need to bend each cathode leg to a 90 degree angle. I bent mine with pliers right below the little nub each LED leg has. This kept each bend at a consistent length. (Picture 1)

Step 2) Next, place 4 LED's into the template you created in the previous step. If all went according to plan your LED's should overlap by about 1mm. (Picture 2) Solder all the LED's together at the place they overlap. Repeat this step 3 more times and fill up your template.
When you're done you should have 4 rows of 4 LED's soldered together. (Picture 3)

Step 3) Now you will need to cut two pieces of solid uninsulated wire and straighten them. The wire should fit the length of the cube. These pieces of  wire will connect the 4 rows of LED's together to form a layer. Place one wire after the first row of LED's and one wire right before the last row of LED's. (Picture 4) Feel free to cut off the remaining legs of the 4 cathodes.

Step 4) Remove the layer and set aside.

Repeat steps 2-4 to create 3 more layers of LED's!

Step 4: Soldering the LED Layers Together

Now you're ready to solder all the LED layers together!

Put one of your LED layers back into your template ( Picture 1). Now bend the end of each anode leg slightly so it will be easier to solder the layer to the one on top of it. (Picture 2)

Place a second layer of LED's on top of the first one. You might want to use something to support the second layer so that it stays perfectly aligned and spaced between the first one. I eyeballed it and used extra hands to hold the second layer above the other one. Now solder the bent ends of each anode leg to the anode leg above it.(Picture 3) Repeat this step for your last two layers. On the last layer don't bend the end of each anode leg since you won't be soldering a layer above it.

Step 5: Circuit

Now you should have finished cube!

Pull the remaining anode wires at the bottom of your cube through the top of the case. 

Before you start wiring up the circuit cut 4 pieces of solid uninsulated wire. Make sure that your pieces of wire are long enough to poke through the top of the case since you will need to solder them onto a stripboard later.(Picture 1) You will then need to bend the end of each of the wires at a 90 degree angle. Thread the wire through your 1.5mm holes and solder them to each common cathode layer. (Picture 2)

To start making your circuit grab your stripboard and resistors. I cut my board into strips so it would be easier to poke 4 of the 16 anode wires into it later instead of poking all of the 16 anode wires into it at the same time. If you are using the stripboard with copper leads make sure you follow the leads and don't accidentally cut it in the wrong direction.(For reference see Picture 4 and 5) If the leads are not connected the circuit won't work!

After you have 4 strips solder 4 resistors onto each of them. (Picture 3 and 4) I placed each strip onto my cube first to mark where each leg poked through so my resistors would fit perfectly with each anode leg. The cathode legs will not need resistors! Repeat this step for each strip.

You should now have 4 strips of stripboard and 4 resistors on each board. Cut off the remaining legs of each resistor.

Next, place a stripboard back onto the cube and solder the 4 anode legs to it. (Picture 6 and 7 )Repeat this step for each board! For the board that has the common cathode legs that also poke through it just solder those legs to any blank column on your stripboard. They don't need to be connected in the anode legs and resistor columns. (Picture 8) 

Your board should look this..(Picture 9) and then cut off all the remaining legs so it looks like this ( Picture 10).

Now get your 20 jumper wires and solder the wires on top of each soldered anode leg and cathode leg. (Picture 11) 

Step 6: Prototyping Shield

Since it's difficult to plug stranded wire into the Arduino board I used a Proto Shield to make the process easier.

You will need to solder the header pins onto the shield so that it matches the header pins on the Arduino. 

After soldering the header pins you will now need to place each wire in the correct position so the circuit can work. If you look at your cube from the top follow the order of the pin labels on my picture and solder each wire to the correct port on the proto shield.(Picture 1) Then solder the cathode wires to the correct ports. (Picture 2) Don't make my mistake of soldering the cathode wires to ground, they go into the analog input pins. I soldered my wires next to each correct header pin to create a stronger connection instead of plugging them directly into the pin.(Picture 3)

Alright now you're all done with the wiring! Go ahead and plug your proto shield into your Arduino!


Step 7: The Code!

If you don't already have the Arduino software installed on your computer you will need to do that before moving on. 

If you do have the software download the code for the cube here. https://dl.dropboxusercontent.com/u/21892130/121118%20-%20LED%20Cube/LED_cube_4x4x4/LED_cube_4x4x4.ino I used the code from Matt who posted a tech made easy tutorial on this cube. If you just want to fire up your cube with his code upload it to your Arduino and you're good to go! I powered my cube with a 9 volt battery but you can plug it into your computer as well! I also coded a few animations on my own cube and I'll explain how to here if you're interested in doing your own too.

So each block of LED's is represented by binary numbers. A row of LED's will look like this in the code B0000. To light up an LED simply replace a 0 with a 1. Like B1000 to light up one LED or B1010 light up two LED's,etc. In each line of code you will have 16 blocks of binary numbers and the single number following the 16 blocks will represent the duration each line is played. (Picture 1)

In my picture you can see I divided 4 blocks of binary numbers into 4 different sections.(Picture 2) Each section represents a different row of leds. 

It helps to delete all the code but one line and then turn all the binary values to 0 except for one. (ex. B0001,B0000,B0000,B0000 B0000,B0000,B0000,B0000  B0000,B0000,B0000,B0000  B0000,B0000,B0000,B0000)  Only one LED should light up. It will take some time to play around with code and really see how it works. 

Alright I hope this tutorial was helpful for you guys! 

(Some code I added! )
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,6,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,6,
B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,6,
B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,6,
B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,6,
B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,6,
B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,6,


B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,6,
B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,6,
B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,6,
B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,6,
B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,6,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B1111,B0000,B0000,6,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,6,


/*run around*/
B0001,B0000,B0000,B0000, B0001,B0000,B0000,B0000, B0001,B0000,B0000,B0000,  B0001,B0000,B0000,B0000,6,
B0000,B0001,B0000,B0000, B0000,B0001,B0000,B0000, B0000,B0001,B0000,B0000,  B0000,B0001,B0000,B0000,6,
B0000,B0000,B0001,B0000, B0000,B0000,B0001,B0000, B0000,B0000,B0001,B0000,  B0000,B0000,B0001,B0000,6,
B0000,B0000,B0000,B0001, B0000,B0000,B0000,B0001, B0000,B0000,B0000,B0001,  B0000,B0000,B0000,B0001,6,
B0000,B0000,B0000,B0010, B0000,B0000,B0000,B0010, B0000,B0000,B0000,B0010,  B0000,B0000,B0000,B0010,6,
B0000,B0000,B0000,B0100, B0000,B0000,B0000,B0100, B0000,B0000,B0000,B0100,  B0000,B0000,B0000,B0100,6,
B0000,B0000,B0000,B1000, B0000,B0000,B0000,B1000, B0000,B0000,B0000,B1000,  B0000,B0000,B0000,B1000,6,
B0000,B0000,B1000,B0000, B0000,B0000,B1000,B0000, B0000,B0000,B1000,B0000,  B0000,B0000,B1000,B0000,6,
B0000,B1000,B0000,B0000, B0000,B1000,B0000,B0000, B0000,B1000,B0000,B0000,  B0000,B1000,B0000,B0000,6,
B1000,B0000,B0000,B0000, B1000,B0000,B0000,B0000, B1000,B0000,B0000,B0000,  B1000,B0000,B0000,B0000,6,
B0100,B0000,B0000,B0000, B0100,B0000,B0000,B0000, B0100,B0000,B0000,B0000,  B0100,B0000,B0000,B0000,6,
B0010,B0000,B0000,B0000, B0010,B0000,B0000,B0000, B0010,B0000,B0000,B0000,  B0010,B0000,B0000,B0000,6,
B0001,B0000,B0000,B0000, B0001,B0000,B0000,B0000, B0001,B0000,B0000,B0000,  B0001,B0000,B0000,B0000,6,
B0000,B0001,B0000,B0000, B0000,B0001,B0000,B0000, B0000,B0001,B0000,B0000,  B0000,B0001,B0000,B0000,6,
B0000,B0000,B0001,B0000, B0000,B0000,B0001,B0000, B0000,B0000,B0001,B0000,  B0000,B0000,B0001,B0000,6,
B0000,B0000,B0000,B0001, B0000,B0000,B0000,B0001, B0000,B0000,B0000,B0001,  B0000,B0000,B0000,B0001,6,
B0000,B0000,B0000,B0010, B0000,B0000,B0000,B0010, B0000,B0000,B0000,B0010,  B0000,B0000,B0000,B0010,6,
B0000,B0000,B0000,B0100, B0000,B0000,B0000,B0100, B0000,B0000,B0000,B0100,  B0000,B0000,B0000,B0100,6,
B0000,B0000,B0000,B1000, B0000,B0000,B0000,B1000, B0000,B0000,B0000,B1000,  B0000,B0000,B0000,B1000,6,
B0000,B0000,B1000,B0000, B0000,B0000,B1000,B0000, B0000,B0000,B1000,B0000,  B0000,B0000,B1000,B0000,6,
B0000,B1000,B0000,B0000, B0000,B1000,B0000,B0000, B0000,B1000,B0000,B0000,  B0000,B1000,B0000,B0000,6,
B1000,B0000,B0000,B0000, B1000,B0000,B0000,B0000, B1000,B0000,B0000,B0000,  B1000,B0000,B0000,B0000,6,
B0100,B0000,B0000,B0000, B0100,B0000,B0000,B0000, B0100,B0000,B0000,B0000,  B0100,B0000,B0000,B0000,6,
B0010,B0000,B0000,B0000, B0010,B0000,B0000,B0000, B0010,B0000,B0000,B0000,  B0010,B0000,B0000,B0000,6,

/*wrapper*/
B0001,B0000,B0000,B0000, B0001,B0000,B0000,B0000, B0001,B0000,B0000,B0000,  B0001,B0000,B0000,B0000,6,
B0001,B0001,B0000,B0000, B0001,B0001,B0000,B0000, B0001,B0001,B0000,B0000,  B0001,B0001,B0000,B0000,6,
B0001,B0001,B0001,B0000, B0001,B0001,B0001,B0000, B0001,B0001,B0001,B0000,  B0001,B0001,B0001,B0000,6,
B0001,B0001,B0001,B0001, B0001,B0001,B0001,B0001, B0001,B0001,B0001,B0001,  B0001,B0001,B0001,B0001,6,
B0001,B0001,B0001,B0011, B0001,B0001,B0001,B0011, B0001,B0001,B0001,B0011,  B0001,B0001,B0001,B0011,6,
B0001,B0001,B0001,B0111, B0001,B0001,B0001,B0111, B0001,B0001,B0001,B0111,  B0001,B0001,B0001,B0111,6,
B0001,B0001,B0001,B1111, B0001,B0001,B0001,B1111, B0001,B0001,B0001,B1111,  B0001,B0001,B0001,B1111,6,

B0001,B0001,B1001,B1111, B0001,B0001,B1001,B1111, B0001,B0001,B1001,B1111,  B0001,B0001,B1001,B1111,6,
B0001,B1001,B1001,B1111, B0001,B1001,B1001,B1111, B0001,B1001,B1001,B1111,  B0001,B1001,B1001,B1111,6,
B1001,B1001,B1001,B1111, B1001,B1001,B1001,B1111, B1001,B1001,B1001,B1111,  B1001,B1001,B1001,B1111,6,
B1101,B1001,B1001,B1111, B1101,B1001,B1001,B1111, B1101,B1001,B1001,B1111,  B1101,B1001,B1001,B1111,6,
B1111,B1001,B1001,B1111, B1111,B1001,B1001,B1111, B1111,B1001,B1001,B1111,  B1111,B1001,B1001,B1111,6, 

Step 8: Schematic

Here's a schematic for the cube!

This schematic only shows the wiring for pins A0,A1, D3, D7, D11 and the 4 cathode wires A2,A3,A4,A5. The remaining blank resistors just follow the same pattern as the LED's I've shown. If I were to map out the whole cube it wouldn't fit on one page.