My latest 4x4x4 cube, using pink LEDs and made for my girlfriend

Make your own 4x4x4 LED cube with an Arduino Uno

Pretty in pink

So, a few weeks ago I shared my LED cube on the site, but didn’t give a full walkthrough on how to build one.

Since then I’ve actually built a couple more, and I’ve pretty much got the process memorised now..

This LED cube uses an Arduino Uno micro-controller to create a stunning light show, and in this guide I’ll show you how you can make your own, as well as give you some advice on the things you should and shouldn’t do.

By the way, pink is optional.  This cube is for my girlfriend!


Before you start

Before I get into part lists and then actually showing you how to make the thing, there’s a few things to say about the process.

First of all, you don’t need to understand or even care about the circuitry or the programming of this cube in order to build it.  I’ll be describing the process in enough detail to take anyone with some basic soldering skill through to completion.  That being said, I’ll also try and explain a bit of theory about the cube so that, if you want, you can understand about it.

Second, patience is key for this project.  If you take your time and plan carefully then you’ll come out with something that looks the part.  If you rush, cut corners or guess at things then it won’t look anywhere near as good.  Practice also makes perfect.  The cube that I show you in the pictures in this guide is actually my third cube using this design, so don’t be discouraged if yours doesn’t look as good.  Of course, if yours turns out better, then I hate you.

Lastly, the most important thing in this project is that you have fun.  I’m assuming that you’re interested in electronics, because you’re reading this article, so let’s get cracking on the next page with a part list.



Next Page: Part List

137 thoughts on “Make your own 4x4x4 LED cube with an Arduino Uno”

    1. So the 4 cathodes are connected using the 4 pieces of wire that are threaded through the cube from the bottom (one per layer). At the other end they’re connected as per the diagram to the Arduino.

      1. sketch_mar19a.ino:10:1: error: ‘prog_uchar’ does not name a type
        sketch_mar19a.ino: In function ‘void loop()’:
        sketch_mar19a.ino:447:23: error: ‘PatternTable’ was not declared in this scope
        Error compiling.

    1. Hi, the jewellers wire is used for two things:

      1) For connecting together strips of four LEDs in order to form each of the layers
      2) To connect the common cathodes of each layer to the Arduino.

      It doesn’t really matter where you place these strips of wire, though I tend to put them just inside the cube structure. You need to attach one piece of jewellers wire to each of the layers, which will then feed down into your case so that you can connect the layers to the Arduino.

      1. Or you can use solder wire itself, though i found this to be incredibly weak and has a tendency to melt (cant understand why though) :)


    1. Each layer of LEDs should have a common cathode. You can cut off any LED legs or jewellers wire that protrude from the layer, the important thing is that all of the cathodes on the layer are connected together.

  2. I have made a 3x3x3 cube……. thanks to ur instructions…… but I couldn’t get jweller’s wire…. any idea from where can I get it online???

  3. MATT thanks for the tutorial it was really helpful.. I would be happy if you share ur codes with us.. !! Thanks in advance bro !!

  4. Hi Matt. Great instructions. I now am the proud owner of my very own 4x4x4 Cube. ( I had to do a more manly Red lol ) My cube does not look that straight though :~) I have made a couple of routines too. Thank you for your clear concise instructions. and some code to start me off.

  5. Hi Matt,

    I’m about to order the part to try reproducing your setup. I’m not familliar with LED mcd, what brightness do you recommand ? Is 200mcd enough ?
    Thank you for thoses great instructions btw.

    1. Hi, 200mcd seems a little low. As an example, the LED’s in my blue 4x4x4 cube are 2000mcd. But, you may find that 200 is enough for you, it depends on whether you want your cube to glow nicely or shine like the sun.

    1. The cube uses persistence of vision to give the impression that all four layers are on at the same time, when in reality only one layer is on at any one time

  6. oke thx, i use the same board. But when i will upload the code to the Uno, the program say; you choose the wrong chipset.. I’ve checked the board setting again, but the setting is on “Arduino Uno”..

  7. Hi,
    thanks for the instructions, but what is about the transistors?
    i have seen in others tutorials that they had used 4 transistors connected to the 4 layers.
    Sorry but my english isn’t good

    1. Hi Emanuel, this design does not require additional transistors. Larger designs sometimes use transistors if the micro-controller board can’t provide enough power to the layers.

    1. Hi, if you use Male/Female then theoretically you would be able to connect the jumpers to the LED legs without solder.

      To be honest, as long as you have one male end and are willing to do a bit of soldering, you’re fine.

  8. Hi Matt, I had read your detailed tutorial and wanted to build one myself too. But I am thinking can I not stuck my ardiuno uno there permanently and replace a barebone? I don’t know how to do that, if you are able to help. Thanks.

  9. Hi Matt, great design and a very easy to follow guide. My question is regarding your program that you listed. I know you made it but would it be possible either for a brief explanation on how you made it, so I can make my own routine, or can you point me in the right direction to learn the codes your using. I have an ruinous book but your code does not match up. Thank you in advance for your help

    1. Hi, I didn’t actually write the program, it was sourced from another guide. It would be quite difficult to describe the way the routines work, the best thing to do would be to play around with it and see what effects you cause on the cube.

  10. Hey Matt,

    Just made one of these with your instructions. I chose 3mm white LEDs but they had considerably shorter legs than yours. I ended up with a much smaller cube. It still looks great, but the soldering is tight!

    Anyway, a great way to spend a day on the weekend and thank you for the inspiration for this (I did look at other guides but yours was the easiest).

    I didn’t use veroboard for the bottom. Instead, I put the cube on the box, pulled the legs out in a ‘Z’ formation to lock it in, then siliconed it in and soldered resistors directly to the base and attached DuPont wires. Cutting the veroboard without my Dremel gave me a headache and too many pulled tracks!

    Thank you and best wishes.

      1. Ok, I’ll email a picture to you.

        My silver wire was a little too thick – 1mm. Something a like 0.6mm would be have been better. Anyway, in real life, you can’t tell and it probable adds strength to the structure.

        Thank you again!

  11. Thank you so much for your instructions I did my own 4x4x4 led cube and I used your pin out put and it seems to work great, However my A0, A1 out put pins if they are used at the same time or 1 at a time the LED light up. If the A0, A1 led or light up with other pins A0, A1 LED will not light up. So I turned on all the LED and the entire column of A0, A1 are not lighting up. Do you know what could be the cause of this issue?

    Thank you
    Adrian W

    1. Hi Adrian, the first thing to check would be a wiring fault. Make sure that there isn’t any solder connecting anodes and cathodes on any of the LEDs, and make sure that your jewellers wire isn’t making contact with any layer other than the one it’s supposed to.
      I did have a similar problem once, and it turned out to be a fault Arduino, so if you have another board laying around it may be worth swapping them out quickly and checking if the problem goes away.

  12. Hi Matt, I actually followed a different site firstly to build my 4x4x4 LED cube. In this method, I ended up constructing my LED’s with 16 cathodes and 4 common anodes. The code provided with the design wasn’t Arduino compatible and I had to build a circuitry according to your instructions which has 16 anodes and 4 cathodes; b,cos your code is Arduino compatible. I have completed the complete structure and the code runs in reverse (obviously, anode is cathode now). In this process the code works but, in opposite fashion. I ended up lighting all the leds and where the leds should turn Off, they come On and viceversa.
    Now, I want to know if there is any possibility in modifying the code with high as low and viceversa; instead of changing the LED’s connections completely? Changing the LED’s anodes and cathodes completely isn’t possible now.

    Any help provided is appreciated….. Thank you!

    1. Hi, I didn’t write the original program so it’s difficult for me to comment on whether it can be easily adapted for “reverse running”. Have you considered just writing your sequences “in reverse” so that it looks how you want?

  13. I have a Problem with the connection.
    I know whats about the 16 Pin – ok.
    But what means Layer 4 – A5, Layer 3 – A4, Layer 2 – A3, Layer 1 – A2 ??

    Do i need
    -16 Connections for the “columns”
    -4 Connections to the GRN

    AND 4 Connections for eatch Layer?

    Or is it Possible to change the PIN A5,A4,A3,A2 to GRN ?

    i’m a bit confused.

    BTW. Great Tutorial.

    1. Hi, I’m not sure what you mean by GRN. You need a total of 20 connection for this cube:

      16 cathode connection (one per ‘column’)
      4 anode connection (one per layer)

      The 4 layer connection use A5,A4,A3 and A2

  14. I thought the Uno only had 14 I/O pins. A 4x4x4 needs 16 for the horizontal layers and 4 more for the vertical layers meaning 20 pins to address the cube. I can’t see where you’ve hardware multiplexed pins to address the cube, so have you done it using POV in software? I’ve not looked at the code, I’m just doing a hardware design ATM and anything over 3x3x3 tends to use a simple multiplexer or a more complicated shift register design. Always do it in software I was taught as it’s cheaper!

    Other posters have asked about using transistors to drive the cathode. As the LEDS are on/off in short bursts you can probably get away with not having them, but with a duty cycle approaching 100% I’d be tempted to add them. they’ve cheap and help protect your uno :) as it can sink a max of 40ma per output.

    A nice tutorial and you’ve made a great cube :)

    My next design will be an LED clock. I was going to do a nixie tube, but they’ve quite expensive!

  15. Hey, i’m try’n to make my own code. But one thing i don’t understand. Witch part in your code is relevant if you try to activate some LED’s in diffrent layers? I know how to active LED’s in one Layer but i don’t know how to in more layers (but not all) at the same time. Hope you understand what i mean.

    1. Hi, if you refer to page 7 of the guide, there’s an image of some sample code. Each line of the code represents one line of animation for all four layers. Each LED in the cube is addressed in one of these lines. If there is a “1” then the LED is on. If there’s a “0” then the LED is off

  16. Love your build here I am building this cube with a Arduino Nano and don’t get the cube/chip connections, what columns go where? Your Diagram shows from the top looking down I understand that but it says to connect columns to pins 1,2,3,4 etc well pin 4 on a nano is ground we can’t have that? Can you please give me the columns connections from the top like you did but with the way the pins are named on the chip TX, RX, RST, GND, D2, D3, A1, A2, etc. Please

    Thanks Anthony

    1. Hi Anthony, the layout diagrams above show the pin names, not the pins as seen from left to right. So, when I say connect to pins 1,2,3,4 I mean connect to digital IO pins 1,2,3,4, as shown on the board.

      The pin names on a Nano and Uno correspond so there should be little issue using a Nano.

      There’s an excellent CAD drawing that shows the pinouts here:

      Have fun with your cube and be sure to email me a photo ( so that I can add it to the gallery of cubes made using this guide.

  17. I got it all soldered up now and uploaded your program and only the bottom 2 rows are working correctly? Any guesses, I checked all my solder joints and tested the lights individualy and they work yet the top rows don’t work. When I put an aligator clip on a ground connection from one of the rows thats working I thought it would mirror that row, but it just shuts that row off too? any help would be appreciated as I’m excited now that I’ve seen the light LOL.

  18. Hello i was able to make the led cube, it was nice and easy..

    Now I am planning to make one that will change patterns when we clap

    can you please suggest something what should i do, I have no idea how to proceed

    1. Hi, congratulations on finishing the cube, I’d love to see a picture so that I can add it to the gallery. Adding sound sensitivity to this design is going to be very difficult; there are no inputs left on the Arduino to allow for a microphone. There are tutorials out there that help you to make a sound reactive cube, but they use different connectivity and different programming to this cube. Best of luck!

  19. Hey matt,,
    i really want to thank you for being such a nice guide….
    i completed my very first led cube,it took me a day and half to complete….nothing went wrong there were no questions to be asked…your guidelines are perfect..thank you for your every effort you made for this nice presentation…i really appreciate your work..keep it up brother. THANK YOU.

        1. I think it’s best to look for an existing guide online, I’m afraid I don’t have the capacity to write up a guide at the moment, and it would only be a carbon copy of an existing guide

  20. Hello,

    I was need to edit code like this

    int LEDPin[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, A0, A1};
    int PlanePin[] = {A2, A3, A4, A5};

    to get it working.
    Board Arduino Leonardo.
    IDE 1.5.6-r2

    Thanks for tutorial.

  21. Just finished building my cube according to your tutorial.. works fine and looks nice!!
    A big thank you from Germany!!

  22. Very simple question, if there are 16 lines using a 5v source, 4 leds in series using 2.1v @ 20mA each, the math for me is not adding up which is making buying the correct resistors damn near impossible. 5 volts should not be able to power all 4 leds in series. I just need to know what resistors to buy lol. I am building two cubes, 1 using blue leds 3.2v @ 25mA, and the other with green leds 2.1v @ 20mA. Much appreciated.

  23. Hi Matt,

    I have one question about the cube.. I’m using a arduino nano for it. Everytime i start a loop.. The more leds i use the less light are coming of the leds.. For example if i use only one led this led is more litt then when i use 5 leds.. Any idea how this may come?

    1. Hi Jereon, I’m not quite sure, I’ve never experienced this myself. Off the top of my head I have two questions: What power supply are you using, and what resistor values have you used for the Anode legs? I’ve never used a Nano so not quite sure how much power it can deliver, but I’d imagine enough to power 16 LED’s at a time (which is all the cube ever actually lights as it switches layers really quickly)

      1. Hi Matt,

        The powersuply will be the arduino nano feeding from USB. But when i power it by a 9V battery it doesnt seem to change a thing..
        I use 3mm green led lights with the following specs: forward V: 2.0,
        Max continuous Forward Curr: 30mA. I use these leds with a 100 Ohm resistor.. The max peak is 75mA.

        And is there any way to fade the leds in a shape..?


  24. ehi matt tengo todo el cubo armado ala perfecion pero mi arduino no enciende ningun led como hago para encender o arracar todos los led ya todo esta armado tal cual necesito saber como puedo encender todo mi cubo led

  25. si quieres te mandare un video de como esta armado mi cubo led pero por favor ayudame ya estoy en la parte final de este proyecto y necesito de tu ayuda quedo atento a tus respuestas por favor comunicate ami correo

  26. Great instructable, created it today and it works ! Thanks a lot dude !
    Only had to change the code on one line:
    const uint8_t PROGMEM PatternTable […]
    (instead of prog_uchar PROGMEM PatternTable […]) on Arduino 1.5.7 and Uno R3.
    Looks great, again, be honored and I´m unworthy….

  27. hey matt greetings thank you for your cooperation in the project was a great help I send the video to your mail was a difficult but trabao we got to my girlfriend and I
    I send thanks from Colombia salute
    sorry for not speaking another language but your material is buenisimo you bet to make the 8x8x8 cube

  28. Pingback: Catherine Davis
  29. Why dose my program say Arduino: 1.5.8 (Windows 8), Board: “Arduino Uno”

    Build options changed, rebuilding all

    sketch_nov20b.ino: In function ‘void loop()’:
    sketch_nov20b.ino:13:1: error: ‘prog_uchar’ was not declared in this scope
    In file included from H:\Documents\LED cube\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,
    from sketch_nov20b.ino:2:
    sketch_nov20b.ino:13:12: error: expected ‘;’ before ‘__attribute__’
    sketch_nov20b.ino:419:1: error: a function-definition is not allowed here before ‘{‘ token
    sketch_nov20b.ino:487:1: error: expected ‘}’ at end of input
    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.
    dont know what his means can some one help it means i cant upload the code
    ps the code is your one

  30. Hi Matt .. i don’t understand the part of the Fabricating and Circuitry. the diagram? on how to connect the jumper in the arduino and into the stripboard… i’m confuse that part ..

  31. the code you gave won’t upload says error compilling

    this is the copied error message

    Arduino: 1.5.8 (Windows 7), Board: “Arduino Uno”

    Build options changed, rebuilding all

    sketch_dec05a.ino: In function ‘void setup()’:
    sketch_dec05a.ino:3:2: error: ‘code’ was not declared in this scope
    sketch_dec05a.ino: In lambda function:
    sketch_dec05a.ino:24:1: error: expected ‘{‘ before ‘int’
    sketch_dec05a.ino: In function ‘void setup()’:
    sketch_dec05a.ino:24:1: error: expected ‘;’ before ‘int’
    sketch_dec05a.ino:26:14: error: a function-definition is not allowed here before ‘{‘ token
    sketch_dec05a.ino:30:13: error: a function-definition is not allowed here before ‘{‘ token
    sketch_dec05a.ino:56:1: error: expected ‘}’ at end of input
    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

    got any thoughts
    thanks :)

  32. Hi Matt!
    I am facing a problem in making the case to fit the arduino and the wires. Could you please tell me what material did you use for the case?
    I don’t know what kind of mechanism to use in the case- sliding or using screws. Could you please help me here?

  33. Hai RC mania7, first you have to make sure that your Arduino board work properly (you can check it by using example programs like blink led) if its working properly. then you have to make sure it is Arduino 1.5.7 or UNO R3,if it is either one of above then you have to change one line in the code which line give the error ….

    Only had to change the code on one line:

    const uint8_t PROGMEM PatternTable[ ]

    (instead of prog_uchar PROGMEM PatternTable[ ])
    on Arduino 1.5.7 and Uno R3.

    one of our friend just say it ……

    thanks Carlos……

  34. Hi

    I Have upload your code but i got error msg :

    Arduino: 1.6.0 (Windows 7), Board: “Arduino Uno”

    led_Cube_4x4x4.ino:10:1: error: ‘prog_uchar’ does not name a type
    led_Cube_4x4x4.ino: In function ‘void loop()’:
    led_Cube_4x4x4.ino:447:23: error: ‘PatternTable’ was not declared in this scope
    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

    can you help me fix this,

    thanks before :)

  35. HI…

    I just upload your code into my arduino and i got error msg:

    Arduino: 1.6.0 (Windows 7), Board: “Arduino Uno”

    led_Cube_4x4x4.ino:10:1: error: ‘prog_uchar’ does not name a type
    led_Cube_4x4x4.ino: In function ‘void loop()’:
    led_Cube_4x4x4.ino:447:23: error: ‘PatternTable’ was not declared in this scope
    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

    Please help me fix this

    thanks before

  36. Hi
    I have problem with code ?
    I download the code bout it give me error
    Arduino: 1.6.1 (Windows 8.1), Board: “Arduino Uno”

    _4x4x4_single.ino:10:1: error: ‘prog_uchar’ does not name a type

    _4x4x4_single.ino: In function ‘void loop()’:

    _4x4x4_single.ino:446:23: error: ‘PatternTable’ was not declared in this scope

    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

  37. Dear Sir,
    can you please upload the circuit diagram for this cube. Also I want to know how to generate the different pattern in the code? Is it by using array.
    Thanks in advance.

  38. I have a 4x4x4 rgb led cube freetronics one that was working. I tried to connect MSGEQ7 breakout board and got nothing maybe I didn’t connect properly. So I thought leave it(msgeq7). I am going to use without msgeq7, but now my cube doesn’t work.Is there any advise how to bring the cube to work again, and what has happen. Please if any one can give a clear instruction how to do it

    Thank you

  39. I don’t know if you’re still monitoring this feed, but after having read many versions of how people put these together, the cathode layer & anode column with current limiting resistor seems to be the most common pattern.

    I’m having a problem rationalizing why folks who do this with just resistors between their cube and arduino pins aren’t burning the board out.

    If you need between 20 and 30 mA per led and you can light up to 16 at once, the arduino pins can supply 40 mA and the ground pin can sink 200 mA, but the entire board can’t supply more than 200 mA and 20*16 exceeds that handily.

    I’m suspecting that few actually light all 16 led’s at once or that they can get away with it for some short amount of time OR that the software actually cuts even the layer in half with a persistence of vision approach to limit to 8 on at once.

    I suspect and am trying to verify that this is the reason why people use transistors. The math just doesn’t work for me otherwise: 16*20 = 320 > 200mA…

    Any thoughts?

  40. Arduino: 1.6.4 (Mac OS X), Board: “Arduino Uno”

    sketch_may22a:10: error: ‘prog_uchar’ does not name a type
    sketch_may22a.ino: In function ‘void loop()’:
    sketch_may22a:447: error: ‘PatternTable’ was not declared in this scope
    ‘prog_uchar’ does not name a type

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

    Keep getting this error ?

  41. They have changed the way PROGMEM works. In the code before the patterns star change the array command to this:

    PROGMEM const unsigned char PatternTable[] = {

      1. If I took the time to make sure every article on the site was current then I wouldn’t have time for much else. I wrote this over two years ago, I’m afraid I don’t have the time to maintain it.

  42. Hi Matt,
    I loved this project, I completed it in under an hour and it works great, can you create a community code type of thing so that people can post their own codes for this and make them downloadable for other users.
    Thanks, Alex

  43. Matt, I just finished this project. Was a little intimidated at first, given I’m fairly new to electronics. Your instructions were very easy to follow. For my cube, I used 4 different colored LEDs (R,B,G,Y) with the same color in each column, just had to use different resistors for G & B vs R & Y. The intensity looks very uniform. No problems with the code at all. This has really motivated me to keep going! Next I’m going to build a cube that I can drive independent of an Arduino…. Awesome!

  44. Hi, im not sure if you are still replying to comments on here, but I got a 70x90mm prototype board and it’s just a little too big for my box. It doesn’t look like any circuitry runs through it, is it okay to cut it down to the dimensions I need it at?

    1. Absolutely fine, prototype board is just copper tracks etched onto a hard surface, you can just use a saw to cut it or score it with a knife and snap it.

Leave a Reply