Introduction: Arduino 4x4x4 LED Cube


     This instructable will cover the building process of an 4x4x4 LED Cube. I will be using an Arduino to control the LEDs.  Since the Arduino (Freeduino) has a total of 20 pins (including the analog pins) we will not need to have any multiplexing or shift registers.  I will take you though what i did in order to build the cube and create some designs of your own.

Step 1: Bill of Materials

Bill of Materials

 For this project I used the freeduino Arduino. Because the Freeduino has a total of 20 I/O pins (with using the analog pins) we will not need and multiplexing or shift registers. So all we will need for our project is:

1. LED x 64
2. Resistors x 16
3. Arduino x 1
4. Perforated PCB
5. Soldering Iron
6. Drill (for the jig)
7. Piece of wood (for a jig)


   I have found and to be good suppliers of small electronic components in general and are currently the only two that I have purchased anything from.

Step 2: Choosing LED

LED Type:

LED’s come in different shapes, sizes and colors. For this project we will need diffused through hole LED’s. When an LED is diffused is disperses the light in all directions rather than mainly toward the top of the LED. By using diffused LED we will have get good color out of our LED’s from the side of the cube. Since we will only have a cube that is 4 LED deep I chose to use 5mm super bright LED’s from Sparkfun. 3mm LED’s will work just fine for this small of cube the fall back from brighter LED is when you have a large cube and cannot view the LED’s in the center.

The LED’s I ordered were not diffused this is not that big of problem all you need is some sand paper (a dremel is faster) to sand each LED will light up all parts rather than the focal point at the top.

Test your LED's:

I would recommend that you test each LED in a bread board before soldering. Simply use the +5v and connect that to a resistor (size discussed later) and to the LED just to make sure each LED lights up it would be bad to build the cube with a faulty LED in the middle somewhere.

LED Layout:

Most LEDs positive pin (anode) is the longer pin coming out of the LED and the negative (cathode) is the shorter pin. You can also look at the little metal inside the smaller metal piece is the positive end (anode) of the LED.

Step 3: Choosing the Resistors:

The resistors you end up using depend on the LED’s that you order. Since only one LED in a column should be on at once we only need to use one LED in our calculation. Using Ohms Law V = IR we can calculate the size of resistor.  This may require looking at some spec sheets but all we need to know is max operating current and the voltage drop. The LED’s I used have a voltage drop of 3.4 and a max current of 20 mA. To find the resistor size we can plug these into (Volts – Voltage drop)/(Max Current) = R. Since the arduino will be putting out 5 volts we get (5-3.4)/.020 = R. Solving for this gives a resistor size of 80 ohms that would be allowing for the max current. To have longer LED life I used just a tad larger resistor of 100 ohms to better protect the LED’s.  I was able to find a good price for resistors on digikeay and since we do not need a certain tolerance or anything these will be pretty cheap.

Step 4: General LED Cube Information

 The cube I am constructing will be a 4x4x4 in other words it will contain 64 LED’s with 16 columns and 4 layers. Each column will be the LED’s positive pins connected together allowing 5 volts to pass to all the LED’s in that column. The Layers will consist of the LED’s negative pins connected together To control the LED’s we will be able to supply 5 volts to the column and let the layer connection go to ground. In order to prevent a column from drawing to much current there should only be one layer on at a time.

How do we light up the entire cube at once you ask? Well, we will use something call persistence of vision. An LED leaves an afterimage in the human eye, in other words even when the LED is turned off for a fraction of a second our brain perceives the LED as still light up.

Using this we can control each LED in the cube with only a total of 20 I/O from our arduino. For example if we want to light the third LED on the fourth column we will simply set the output to that column to HIGH (5 V) and the output for that layer to LOW (0 V) thus creating a ground and allowing current to flow and the LED lighting up.

Step 5: Constructing the Jig

In order to solder up a good looking symmetrical cube we will need some help. A jig can be thought of as a template that we will use to hold each layer in place while soldering. To create the template we will need a flat piece of wood that will be able to hold your cube, a drill and some measuring tools.  Depending on the size of your LED's the size of your holes will be different.  Try to find a bit that will allow the LED's to fit snug in the hole but not to tight.

To determine the size of your cube you will need to measure the bent cathode portion of the LED. My bent LED turned out to be about 25 mm therefore I drilled my holes roughly 23 mm apart to allow me 2 mm in order to solder the cathodes together.

Step 6: Constructing the Cube Layers

Now that we have the jig in place we can start building the individual layers. When soldering try not to heat up the LED’s too much if they get too hot it could destroy the LED, so try to solder faster when soldering close to the LED.

To start we will have one LED whos negative pin will go outside the cube.  Next start placing LEDs and soldering as you go I recommended that you complete the row where the pin is sticking out.  Then solder up the other rows to that main row.

Step 7: Constructing the Cube

Now that we have all of the pins it is time to start soldering up the layers.  Place the best looking layer you built back into the jig.  In order to be able to connect the positive pins we need to bend the higher layers pins enough so that the pin goes around the lower layers LED and we can solder to that lower pins positive pin. 

To hold up the Cube while i soldered I used erasers that i cut to the correct size.

Simply continue this step until all of the layers are soldered together.

Step 8: Connection

Due to popular demand, here is a diagram of the connections.

Step 9: Base and Soldering Resistors:

For the base is is pretty open ended on what you would like to do.  For mine I simply used a PCB (or glued PCB together) to solder my cube to.  Once i had my cube done i soldered wires from each column to a resistor. Each resistor was connected to another wire that i planed to plug the Arduino into. You will also need a wire soldered of each layer allowing for negative control (no resistor needed). You can make this part look alot better than mine but for time reasons i just soldered it up quick.

Step 10: Base/Box

After awhile i got tired of wires hanging everywhere and my cube looking unfinished so i decided to build a box for it.n  After running to the local hardware store I found some cheap scrap counter top and some acrylic.  Using some saws at the parents house I was able to build a base and as you can see I was able to hide all of the wires inside. I added some spray paint to the PCB and my cube was starting to look pretty good. Next comes the acrylic.  This part was a little harder. We did not have the correct tools to saw through the acrylic so I decided to use a box cutter with a new blade!  Using this you can make slices on the acrylic were you would like the cut and attempt to break the acrylic on that line.  There are some good videos online of how to do this.  I then supper glued the pieces together which ended up not being as clear as I thought it would be (I may just need to clean it better).

Step 11: Programming:

Programming can take some time some tutorials have good condensed code that is easier to do designs but again for time reasons i was not able to spend much time doing that.  However I was able to do some designs and looking at them will let you better understand what is going on.  I provided my code at the bottom (its kinda sloppy)!

The ground/negative/layer pins:

   Remember the Persistence of Vision since we want to be careful to only have one layer on at a time (although I have made the mistake and am pretty sure the arduino can handle it but why try and break things?).  Since the layers are ground they are backwards from the column pins.  When we want to ground a layer we set the pin in the code to LOW.  This creates a difference in potential allowing current to pass and the LED to be lit up.  When we set the ground pins to HIGH no there is no potential difference and the LED's do not light up.

The Column/Positive pins:
    To control the column pins we can set the pin number to HIGH thus allowing 5 V to flow out of the pin.  So when a specific layer has been grounded the 5 V will flow and the LED on that column and layer will be lit up! If we do not want a LED on that column to be lit up when a layer is grounded we can set that column to LOW and the LED will not light up.

Here is a video of my cube in action! The acrylic box turned out a little hazy but I removed it in the second half of the video so you can see how it looks both ways!

Thanks for reading!


Gatlarf made it! (author)2015-07-22

Thanks for the tutorial. Works like a charm!

viveksridhar (author)2013-06-21

Wouldn't the amount of current going through the ground pins blow them out? Like if all the LEDs in one layer are on, you'd need 16x20mA of current for the ground pin on that layer, and doesn't each pin on the Arduino only output like 40 or so mA?

I thought that was why you needed a transistor for each layer, because the arduino couldn't sink the right amount of current to ground.

Toggle252 (author)viveksridhar2015-05-09

Did you ever figure this one out? bc im confused here as well

boxman117 (author)2013-05-02

are you soldering to the anodes or cathodes

koontzoo (author)boxman1172014-11-18

the layers will be negative/Cathode and each column will be a positive/anode.

boxman117 (author)2013-04-25

i am wondering what PCB i should get

Phogie7 (author)boxman1172013-04-25

Any that the holes are not already connected. :)

369ben (author)2013-01-04

Is This called multiplexing where all the cathodes of each layer are soldered together and the anodes of each column are soldered ?

Also why weren't any transistors used as I have seen in other tutorials?


Phogie7 (author)369ben2013-01-21

It sure is.

If you don't want to use your micro controller pins as a power source you can use transistors. :). You can also control the layer grounds using transistors.

WGY (author)2012-12-29

I made my cube and all of the lights work, however, there seems to be a problem with the wiring. Whenever I address a single LED in 6 of the columns, The whole column lights up. This does not happen in 2 columns where the LED's light up individually.
Help would be appreciated!

Phogie7 (author)WGY2013-01-21

Sounds like you are grounding out each layer for those columns. Make sure in the code you are only have one layer ground on at a time. Somehow those 4 layers for the 6 columns are getting grounded make sure the wiring/soldering did not get crossed somehow.

glen247 (author)2012-12-21

Hey thanks a lot for the work i have created 4x4x4 led cube looking at you tutorial. 

telonics (author)2012-11-25

here's my effort using the UNO board.
Thanks Phogie!

glen247 (author)2012-10-25

Hey thanks for the information. i studied and did the same cube
below is the link for the same

taattooed3 (author)2012-08-08

Got my first cube done,waiting on proto board and a few components to actually finish the project but the cube is done and running on an arduino uno R3. Thanks everyone for all instructibles,questions,answered questions and most of all your time and patients.

Phogie7 (author)taattooed32012-08-09

Congrats!! Always feels good to finish a project!

schembri_andrew (author)2012-06-17

Are you sure that an arduino can handle that current? although, only one led should be on any given time, I am still concerned that i could mess up the code, and end up drawing something like an amp from an arduino pin ( .....) . Do you think I should use darlington transistor arrays to the output pins and supply voltage from an external powersupply? many thanks andrew.

Phogie7 (author)schembri_andrew2012-07-10

I think most arduinos are 40mA. If you want to live on the save side I would run them off transistors and a different power supply. Its really up to you I just decided to take the risk. My arduino still works I am sure i messed up the code a time or two but can not say for sure. I just remember the LEDs slowly getting more dim toward the top and i unpluged it as soon as possible. Could also set up functions in the code to handle the grounds. Four functions each one turns on a layer and off the others.

Best of Luck!!

ma7moodz (author)2012-03-08

Okay Im pretty much stuck here..
Where do I connect the the layer's negative control wires to? (the black wires)
Note: Im very new to arduino

Phogie7 (author)ma7moodz2012-05-21

I added a diagram step number 8. I hope that helps if not let me know.

ma7moodz (author)Phogie72012-05-22

It worked!
and here is my result

Phogie7 (author)ma7moodz2012-05-27

Wooo Hoooo!! Looks good!

DeNuzio (author)2012-02-29

Great instructable :) Here is my results.
I used forte1994 arduino's program

Phogie7 (author)DeNuzio2012-05-21

Awesome! It looks good! Not as bent up as mine got hahaha.

argentinoloco87 (author)2012-02-28

hey. ive read your instructions, but im not sure where to connect the leads from the resistors to the arduino? Im not sure what ports to use

Phogie7 (author)argentinoloco872012-05-21

I added a diagram step number 8. I hope that helps if not let me know.

stringstretcher (author)2012-03-12

I just posted an instructable on programming a 3x3x3 cube with an Arduino. It *might* be possible to adapt that to a 4x4x4 and give us even more programming possibilities. One would need to change the pin setup, but that is about all, I think.

earton (author)2012-02-06

I have followed your instructions, definitely the best instructable to help a beginner! I see your map for the columns, but can you tell me which cathode goes to which ground, for the layers?
Much appreciated :)

Phogie7 (author)earton2012-02-12

Thanks! It was my first one so its a little rough around the edges. I wrote a note down to get a circuit diagram up. In the code i set up pins 16-19 up as the ground pins. Those should be analog 2-5. Does that help?

Pizzapie500 (author)2012-01-29

Hi! I finished the cube, but I'm not sure where to attach the 16 columns of positive diodes, to the Arduino. Also I don't know where to put the negative ones either. Can you tell me which one goes to which pin number (like if the first one goes to A0, or like D3)? Sorry i'm new to Arduino, and the other instuctables used too many pieces. Thanks!

Phogie7 (author)Pizzapie5002012-02-12

This would be from looking down onto the cube. Hope it helps! Each number represents a column of the cube and corresponds to an port on the arduino. Let me know if that works and ill add it to the tutorial!


3 7 11 15
2 6 10 14
1 5 9 13
0 4 8 12


Yeah this was my first tutorial and i realized that I did not explain the connections very well.

On the freeduino i was using use the digital outputs for 0-15 and the analog next. So analog 0 corresponds to column 14 and analog 1 corresponds to column 15. Analog 2-5 will be the negative or ground for the 4 layers.

If you need anything else let me know.

AndreD. (author)2012-01-21

Hey Sir...

Can you please explain how you write some letters in your 4x4x4 Cube?

Phogie7 (author)AndreD.2012-02-12

I may have to watch the video again but I do not think there are any letters. If you want to write letters i would suggest building a bigger cube. A 4x4x4 does not give much room to create letters or numbers.

Bruno Silva Pinheiro (author)2012-01-12

Oh, and if you have the electronic circuit, would be great.

Thank you.

Great project, congratulations!


Thanks! Ill make a note to create a circuit and let you know once i get it posted. :)

kelsorj (author)2011-11-16

Great project! I played around with different colors on each layer and it makes for some fun patterns.

Phogie7 (author)kelsorj2011-12-26

Nice! I do like the different colors! I would like to do a RGB one sometime just have to wait for a rainy day to spend some more on the LEDs.

iinzunza (author)2011-11-16

I have a project for a subject, and I decided to do this Cube but I have one condition... I need to use transistors, so my question is... How can I design the circuit using my arduino and transistors???

Phogie7 (author)iinzunza2011-12-26

You could use transistors to control when a specific layer is grounded. Instead of grounding the layers to the arduino you would have each layer go to a transistor. Then you can control the transistor with the arduino and chose when to ground out that layer. So in other words connect the ground for a layer to the collector of a NPN transistor and the arduino to the base and the ground to the emmitter. Then you can control that layers ground by setting that arduino pin on and off.

Brunomaster (author)2011-10-27

Por que está chueco? sabes soldar?

Phogie7 (author)Brunomaster2011-11-01

My cube got abused.... it got smashed by a drunk friend and a backpack! I was able to almost bend it back when i put it in the case.

I hope Google Translate is accurate :)

Mi cubo se abusa .... que se estrelló por un amigo borracho y una mochila! Fui capaz de casi lo doble de nuevo cuando lo pongo en el caso.

Jiax (author)2011-11-01

I don't get how you connect wires to arduino.
My leds will just blink as random and not in order when I use the code. 'Cause I wired them up just randomly. Which ports should I be using?

There is something I do wrong, but I don't know what. Please help!

Phogie7 (author)Jiax2011-11-01

Hmmm I should have put that in there, my bad. I can see how it would be useful to know how to connect everything :). This would be from looking down onto the cube. Hope it helps! Each number represents a column of the cube and corresponds to an port on the arduino. Let me know if that works and ill add it to the tutorial!


3 7 11 15
2 6 10 14
1 5 9 13
0 4 8 12


Michael Dean (author)2011-10-18

Does anyone know where to get an Arduino (i.e. the Uno) for less than what I'm finding them for? I can't really justify paying $30 for one (even tho it is very programmable), when I can get a pair of 556 relay timers for ~$.50 a piece that would perform a similar function; with the right capacitor/resistor setup.

Phogie7 (author)Michael Dean2011-10-18

My only idea would be to look into a freeduino basically same as Arduino but a little cheaper (although I think you have to solder yourself). I have actually used this arduino for multiple projects so that was my justification. Another justification may be to use the Arduino as an AVR ISP, however I do not know much of anything on that. But it would allow you to only have to replace an AVR when done with a project.

Michael Dean (author)Phogie72011-10-19

Thanks Phogie,
I may just do the 556 for my cube. I only plan on having a couple of groups of LEDs in mine turn on and off, so a 556 (i.e. two 555s) should do the trick. That said, I do plan on buying an Arduino in the future, as they are very robust for what you can do with them.

fryddog (author)2011-09-17

I'm having trouble downloading the .pde file you've provided. Any help would be appreciated. I'm hoping it will help me figure out the programming side.

Your instructions have been very helpful. Probably the best I've come across so far. Thanks!

Phogie7 (author)fryddog2011-09-27

Sorry about the long response took a long vacation! :) I had some troubles downloading it also (never tried before) but i included it in a zip folder. This fixed the problem for me. Should just have to extract it once it is downloaded. If you have any more troubles let me know!

Thanks for the complements i am glad to hear it helped!

VoodooVW (author)2011-09-09

This was my first Arduino project. I built this cube because I like the idea of using just the 20 digital pins, LEDs and a few resisters. Everyone at home and work likes this project and want to see what I can get it to do next. I used Paden's original code on this page to test my cube with excellent results on the first try. Here is the first sketch I was able to make funtion myself.

/*  4x4x4 LED Cube
Chase around outside edge, counter clockwise, top to bottom.
By VoodooVw

// Initalize our LED columns (positive)
int LEDPin[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
// Initalize the LED layers (ground)
int LayerPin[] = {16,17,18,19};
// Initalize the outside columns counter clockwise
int OuterEdge[] = {0,1,2,3,7,11,15,14,13,12,8,4};

// The Setup
void setup(){
// Set up LED columns as output and off
for(int pin = 0; pin < 16 ; pin++ ){
// Set up LED Layers as output and off
for(int layer = 0; layer < 4; layer++){
pinMode(LayerPin[layer], OUTPUT);
digitalWrite(LayerPin[layer], HIGH);}}

// Loop to chase around outside edge, counter clockwise, top to bottom
void loop(){
// Setup increment through layers loop
for(int layer = 0; layer < 4; layer++){
// Setup increment through outer edge loop
for(int pin = 0; pin < 12 ; pin++)
// Turn on LEDs starting from first column, top layer
// Keep LED on for this time
// Turn off current lit LED then loop up to light next edge LED
// Once all LEDs have been lit loop all the way up to increment layer


Phogie7 (author)VoodooVW2011-09-14

Glad to hear that it went well! Its always great when projects work on the first test!

About This Instructable




More by Phogie7:TV Dynamic Ambient LightingArduino 4x4x4 LED Cube
Add instructable to: