Introduction: 4x4x4 LED Cube Arduino

Picture of 4x4x4 LED Cube Arduino

After seeing all the different instructables for Led cubes i was still left with a lot of unanswered questions. So after reading everything i could find this is what i got. I decided to make the instructable after building ill try to recreate the process the best i can.

This cube is different from others for many reasons:
1. It connects directly to your Arduino.
2. It uses few components, so its relatively inexpensive.
3. Runs on code that's easy to write. or you can use the ones provided.
4. Everything can be bought at your local Radio Shack

Parts Needed:

  • 64 diffused LED Lights (it cost a lot less to order 1000 off ebay for around $20) (Also i used 3mm LEDs, but 5mm or 8mm would work to)
  • 16 220 resistors
  • 4 22k resistors
  • 4 NPN type Transistors
  • 1-2 Perfboard (The kind with the little copper circles) (you only need one if you are good at compacting your soldering unlike me....)
  • 1 Arduino (I went ahead and bought a MEGA so there's room to expand fro future projects, however UNO has just enough i/o ports)
  • Insulated 22 gauge Wire
  • some craft wire

In all the cost of this cube is relatively low at around $100 (according to where you get your parts)
the Arduino was the most expensive part at around $60 For MEGA and i think a UNO is around $30.
So if you already have a Arduino the cost is brought down to $40.

Knowledge Needed:

  • Basic electronics and soldering
  • Be capable of following directions

Read the ENTIRE instructable before building design options mentioned in last steps.

Original video:

New code 6-10-13:

8x8x8 Led Cube - See Step 8: UPDATE #3

Step 1: Prepare the LED's

Picture of Prepare the LED's

The first thing you must do is make the cube. 

If you look at the pictures of mine the LED's are not all just soldered to each other.  This is because I actually made all the wiring and circuitry when i was waiting for my LED's to get here from China....(Note that it takes about two weeks for the lights to get to you).
Therefore when Finally got the LED's they were a lot smaller than i anticipated, and i did not want to redo my circuit board, so i just made frames out of craft wire to hook all the cathodes to.  After i started to do that i then realized that it would the be shorter than it is tall making it a rectangle rather than a cube.  So that's when i added the vertical columns of wire to solder the anodes too.
The cube is split into 4 layers of 16 LEDS.

All the LEDs aligned in a vertical column share a common anode (+).
All the LEDs on a horizontal layer share a common cathode (-).

Now if i want to light up the LED in the upper left corner in the back (0,0,3), I just supply GND (-) to the upper layer, and VCC (+) to the column in the left corner.

To begin the Construction of the cube use a drill with the proper size drill bit to make holes in a piece of wood.  draw a grid to the size of the cube you want. (this is determined by how long the leads are on your LED's. 

Your going to want to test you LED's before you solder them into place because it would be sad if you put your cube together and had one in the middle that didn't work.  I'm sure they would be pretty hard to replace. So just use a 3v battery between the two legs of the LED. (long leg is positive, short is negative)

Step 2: Solder the LEDs

Picture of Solder the LEDs

To solder all the LEDs together i used alligator clips to help hold everything together. 
As i said before, i decided to to this after i built it, so i don't really have any pictures of the building process.
However the pictures below are excally what it should look like.  These are from Chr's instructable for his 4x4x4 cube.  Also there is additional information on his that may not be included on mine.  So go read his too.

First make all four layers, then solder the layers together.

Step 3: Build the Circuit

Picture of Build the Circuit

The circuit is pretty simple. Each of the 16 columns will connect to a pin on the Arduino through a current limiting resistor. Each of the four levels connects to ground via a NPN transistor when activated by an Arduino pin.

I drew these drawings if you can understand my way of labeling. 

First Make the Transistor arrays:

NOTE: The transistors are only necessary for some of the codes out there. If you plan on writing your own like i did you can skip this and plug the four ground layers directly into the arduino!

Its made with 4 NPN type transistors. and  22k ohm resistors.  In a nut shell connect all the collectors together, theses all go to a ground pin on the Arduino.  Then all four bases should go their own pin on the Arduino. Lastly the Emitters should go to the layers on the Cube. (Look at picture 2 and it will make since.

The first picture is of both boards to understand how they connect to each other and the Arduino.
The second picture is my drawing of the transistor array controlling the 4 ground layers.
The third picture is the actual Transistor ground board. (The Bottom)
The Forth picture is the actual Transistor ground board. (The Top)

Second Make the main cube board: 
All that really happens on this board is that all 16 columns are connected to the Arduino through a 220 ohm resistor. 
Also all four layers come into this board and then leave to the transistor Board.

The fifth picture is of the entire Cube board. As you see all columns are connected to a 220 ohm resistor the another wire comes out the top of the board and goes to the Arduino.  Also you will notice that the wires are kinda on the resistor backwards to common since. this is because the first time i did this i completely forgot the i did some improvising and it is kinda backwards to normal thinking. Therefore you be smart and do it right the first time.  so if you do it right it does not have to look like mine however you can if you want. 

The sixth picture is a close up of all the connections.  The four big solder trails are the 4 ground layers that leave the board to the transistor board.

The seventh Picture is of the top of the board showing where the wires leave and go to.

The eight picture shows where the Layers enter the board.  Just connect a piece of stripped wire to the layer and then bring it down to the board. make sure these wires don't touch any other wires .... this would cause a short.  however take all the insulation off so that you cant really see them in the cube. 

The ninth picture shows the connection between the two boards.  As i said before, i am not that good at soldering yet.  if your good you could cram all this on one board rather than two.

The last picture shows the column numbers so column 1 is connected to resistor 1, and then resistor 1 is connected to pin 13 on can figure out the rest :)

Step 4: Connecting the Cube to Arduino

Picture of Connecting the Cube to Arduino

The cube is connected as follows:

column # 1    2    3   4   5 6 7 8 9 10 11 12 13 14 15 16   L1 L2 L3 L4
Pin#          13 12 11 10 9 8 7 6 5 4   3    2    1    0  14 15  16 17 18 19

Pictures explain better than words.....

Step 5: Programming

First i wrote a few simple codes just using simple digitalWrite commands to turn lights on and off...then i found a few different codes on the internet.  

4x4 LED sequence 1 and 2 are very simple 
LED Show 1 is a full show that found on the internet
LED Show 2 is another one that is different but it does really the same thing over and over
Ledcube 3x3x3 show is one i found. as the title says its only 3x3x3 however it still works on the cube, it just doesn't use all the lights....

All the codes are located in the zip file.
Im currently writing my own code for it and i will put it on here when i finish....

Comment if you have any questions or would like to share ideas or creations!
Thanks for Reading!!

Step 6: UPDATE

Picture of UPDATE

Between using my Arduino for multiple thing I got pretty tired of hooking up 21 wires to the bouts every time someone wanted to see it... So I got some ribbon cable and some pin header. Now it can be plugged in in one easy push. More updates to come...

I ended up cutting this back off, the wires kept shorting out on each-other.

Step 7: UPDATE #2

Picture of UPDATE #2

Its about time right.

So to use the code it requires slight modification to the cube, and i made a whole new instructable to explain this!

It fully explains how to write your own program!
Also once you modify the cube LED Show 1 will look a lot better.

Go right HERE and start writing your own codes!

By the way, I am currently making a 8x8x8 Cube following chrs instructable and I hope to publish my own that explains everything a bit better than he did.
You will see soon!

Step 8: UPDATE #3 - 8x8x8 Cube

About a summer after I created the 4x4x4 cube I stepped up the game to 8x8x8. What makes mine different from others is I have integrated an older iPod nano into it which is then controlled by the arduino for play/pause etc. This allows any music to simultaneously be ran against animation in the LED Cube. The Animation you see on the cube is written and precisely timed to the song, the arduino in no way interprets the music into what you see. If anyone is interested ill provide some more details, but for now here is a video!!


san7776 (author)2016-07-10

Hey Tyler, Can you help me out? I built the cube and tried to run the codeyou have for it, butI keep getting these errors<> How do I fix this? I cannot waitto see it run. Have lots of ideas for patterns, but need the code to work.

LED_1cube_4x4x4_Show_2:15: error: 'prog_uchar' does not name a type

LED_1cube_4x4x4_Show_2:447: error: 'PatternTable' was not declared in this scope

'prog_uchar' does not name a type

jrtumbles (author)2016-04-21

Hey Tyler, Can you help me out? I built the cube and tried to run the codeyou have for it, butI keep getting these errors<> How do I fix this? I cannot waitto see it run. Have lots of ideas for patterns, but need the code to work.

LED_1cube_4x4x4_Show_2:15: error: 'prog_uchar' does not name a type

LED_1cube_4x4x4_Show_2.ino: In function 'void loop()':

LED_1cube_4x4x4_Show_2:447: error: 'PatternTable' was not declared in this scope

'prog_uchar' does not name a type

Thanks a million!

in line10 put
"char PROGMEM const PatternTable[] = {" instead of "prog_uchar PROGMEM PatternTable[] = {"

Hacks4Life101 (author)2016-01-15

Im not sure if its my wiring, but one side of the cube is not lighting up. Any suggestions on what to do?

freddym1 (author)2016-01-07

hello my bucket arm led but have problems with most programming makes Arduino Uno R3 but I only own Arduino Leonardo bale I'm starting in this algujin can help

dvberger (author)2015-05-28

Ungrounded/Not activated layers in an LED cube light dimly

I built a prototype of a 4x4x4 LED cube circuit on a breadboard before committing it to a protoboard following the anode column/cathode layer approach with a set of current limiting resistors between the columns and an arduino controller and close the plane circuits with a set of 4 transistors in the software with an intent to only have a single plane on at a time. Many folks have built these. This is most closely modelled after this project and this one. As I’ve been testing my cube, I found that the fewer the leds that I have lit, the more pronounced an unpleasant effect is where other leds in an activated column (but unactivated plane) light dimly. I’m really unsure why these leds would light up. The effect seems more pronounced with fewer leds being lit at a single time and totally disappears when all 16 leds in a plane are lit. Surprisingly, if I remove all grounding that closes a circuit, the activated column still lights with a diffuse lighting across the leds in the column. I’ve linked a video that shows the effect in the hopes that someone can help me understand what’s wrong. The circuit is basically this minus the shift registers.

kezy (author)2015-02-11

Hello, I'm not really understand about transistors. Where and whom to solder ?

p.s. may be write

TomTin (author)2012-12-25

Hi, I build the cube according to your design. Only thing i did different is that i used a Darlington transitor array uln2803A instead of the transistors you use.
When i run the testprograms all leds induvidually light up. But when I run the full show when one led should be lit up, the whole column lights up.

Help please

manuschka (author)TomTin2015-01-27

Hi, long time ago. But I have the same problem. Do you know something new?

manuschka (author)manuschka2015-01-27

Here is the fix. It worked for me, to switch some HIGH to LOW and LOW to HIGH

manuschka (author)manuschka2015-01-28

jtmanders (author)TomTin2013-02-07

I don't really know how transistor arrays work. But if the whole columns are lighting up then that means your opening up all four grounds (layers)

manuschka (author)2015-01-26

Hi guys, i have already finished my led Cube.

I have tested the LEDs, I can fully control the entire LED cube by using basic commands.

Now I used the multiplexing code, that is downloadable here.

One thing is weird. I use the line


to let light up one led at the bottom left.

But the whole column lights up.

I thought, that it have something to do, with the transistors and the multiplexing functionality. I have now connected all layers with the collector, the grounds go to the emitter and the base is connectet to the arduino.

Can you tell me why the behavior is like that?

Sorry for not perfect english.

SamuelD4 (author)2015-01-23

hey,can i light all of the LEDs at once without damaging my Arduino??

jtmanders (author)SamuelD42015-01-23

Yes, because of multiplexing, in theory only one light is on at time.

Sahilh (author)2015-01-13

How big is the perfboard?

Sahilh (author)Sahilh2015-01-13

Also is Craft Wire just solder? or is it different?

bart.fernhout (author)2014-12-14

The schematics is easy. Even hand drawing. I use E-plan 8 its nicer.

But jtmanders. You say you can do this using the standard Arduino. But its not true. The standard has only 14 I/O and thats including the Analog I/O. To do this project you need at least a Arduino mega. Like you use in the example.

Did make the project, it works great. I only make the mistake to use 2 kinds of LED Bleu light. The one low power of 1.4 V and the high power of 2.7V. I did notice it when i started the project for the first time. I let it run a test program to lit up every tier. Then i saw some lit good and some lit pretty dark.

Now i understand why there was use 2K ohm R insted of 20K Ohm

A lesson for people who want to do this project to. When you use the LED look for the low power use.

E.G. I try to build a 6 X 6 LED Cube. See if it work to.

jtmanders (author)bart.fernhout2014-12-14

The Arduino Uno has 14 Digital I/O Pins and 6 Analog Input Pins that can be used as Digital Output. If I'm not mistaken that is 20, the exact number you need. Its right on the Specifications. Check it out yourself.


bart.fernhout (author)jtmanders2014-12-15

Your are right my mistake. I did read the technical specs and it says 14 i/o with 6 Analog i/o. I translated that as 14 including the 6 analog. But it is what you say and that means that you are right to make it with the Arduino Uno.

That make it a nice project and the result is very pleasing.

진호손 (author)2014-11-19

i want know how to sketch a schematic

plz upload a schematic or send me

gamma_french (author)2013-09-26


This looks awesome! I see the potential of 3-D signs, clocks, and the list of possibilities is endless!

If one makes an 8 x 8 x 8 matrix, would multiple Arduinos need to be cascaded?



jtmanders (author)gamma_french2013-10-19

It would be a lot simpler to just use multiplex circuits to get the needed amount of I/O ports. Go look up chrs instructable.

nstancil (author)2013-06-29

would you need different resistors if you have to use some analog pins?

jtmanders (author)nstancil2013-06-29

I don't believe so...since you are using them as digital pins

Sandman.Gor (author)2013-06-13

Thank you very much
My son and I rode this hub and was very good.

garyfritz (author)2013-05-28

FYI my son built the cube and the LEDs lit very dimly. I checked the voltages and determined there was a 2.4V drop across the LEDs and a 2.4V drop across the switching transistors, so there was almost no voltage across the 220ohm resistors == very little current driving the LEDs. The transistors weren't getting enough base current to switch fully. I swapped out the 22kohm resistors on the transistors for 2200ohm and then the LEDs lit up nicely. Not sure why you didn't encounter this -- maybe different transistor characteristics. We used 2N4401.

Also, be aware that just soldering the LED leads to the LEDs below them makes for very fragile joints. We keep having connections break. You should really make a mechanical connection (e.g. twist the wires together) and then just use the solder for an electrical connection.

twan1 (author)2013-05-03

hello,Each layer independent of the line?(l1,l2,l3,l4?)

jtmanders (author)twan12013-05-04

I don't really understand the question... If you mean each layer has it's own pin, then yes

jtmanders (author)2013-04-12

Hi, thank you!
If you mean like turning one led on and off that's fairly easy to do. For instance say we want to turn on the lower left hand led.
Do something like:

Void loop(){
digitalWrite(ROW1, HIGH)
digitalWrite(COLUMN1, HIGH)

By doing this only one LED Is getting both a power and a ground. So only one will come on.
Hope this helps,

markie (author)2013-03-17

Nice cube and a good instructable!
I'm wondering, if i build an 8x8x8 led cube.. do i have to reprogram the whole thing or can i use your program with a few modifications?

greetz mark :)

jtmanders (author)markie2013-03-17

I'm not really sure to be honest, but just tinker with it and see if you can get it to work. The first two codes (Cube sequence 1 and 2) are just for 4x4x4 i know because i wrote them. But the other ones can probably be edited up. like the 3x3x3 code i included i have been trying for a while to get to 4x4x4 and it somewhat works, with the exception of a few animations. if nothing else search around the internet there's countless codes out there to play with. I know chr (see link) has a really cool code on his instructable. however i don't know if it would work with my setup or not.
If you figure anything out please share it with me.
Good luck,

markie (author)jtmanders2013-03-17

Thanks for your help! and i will let you know if it works for me :)

Hanni43 (author)2012-10-26

Hi, don't think I worded my question right, I use the analog pins for # 14-19 ,my question is ,due have to program the analog pins to output as digital.. ?or can I load your libary in without programing the Analog pins ? Thanks for your time..

jtmanders (author)Hanni432012-10-28

Ok, as long as you specify in the code which pin is which layer/column then it should work. its all according to which code you try to put on there.

When you download the code from here there are Five different one there. The first two (_4x4_LED_Cube_Sequence_1 and _4x4_LED_Cube_Sequence_2) i wrote myself and use basic commands to make it run. The part that needs to be changed according to how you set up your cube is the first things on top.
The C stands for column and L for layer. Refer to step 4 for column and layer numbers. This is what it looks like when you first open it.
int C1 = 13;
int C2 = 12;
int C3 = 11;
int C4 = 10;
int C5 = 9;
int C6 = 8;
int C7 = 7;
int C8 = 6;
int C9 = 5;
int C10 = 4;
int C11 = 3;
int C12 = 2;
int C13 = 1;
int C14 = 0;
int C15 = 14;
int C16 = 15;
int L1 = 16;
int L2 = 17;
int L3 = 18;
int L4 = 19;

so all you must do is change these. For example, change C15 to A0 rather than 14. as far as what part of the cube to put on the analog pins it does not really matter. For simplicity, i would just put C15 = A0, C16= A1, L1= A2, L2= A3, L3= A4, L4= A5.

In the other three codes just look for where the code specifies rows and layers and change them. Not all of them are in the same place or format. All are located before the Void setup.

Hope this helps. If you have anymore questions feel free to ask.
Good Luck!

Hanni43 (author)2012-10-26

Great instr ,have it almost finished ,great directions.Using an Uno & have just enough pins with the analog .Digital from 1 - 13 then have to use analog ,AO-A5 my question is which of the cube would you use the analog . Thanks very much for sharing your project..

jackjackboom (author)2012-08-08

Awesome ible man!! One of my first arduino projects was a 3x3x3 led cube. Led cubes have amazed me so often and in so many different ways. I had to unsolder my led cube after it barely survived two trips via public transport to the local museum for a tinkering festival. I was asked to place it at the Arduino section and it got more attention than the talking head and the roving robot made from an rc toy.
Again, I love your amazing instructable!!

About This Instructable




Bio: “To invent, you need a good imagination and a pile of junk.” ― Thomas A. Edison
Add instructable to: