Introduction: LED Cube 4x4x4

Picture of LED Cube 4x4x4
Amazing 3 dimensional LED display.

64 LEDs makes up this 4 by 4 by 4 cube, controlled by an Atmel Atmega16 microcontroller.
Each LED can be addressed individually in software, enabling it to display amazing 3d animations!

8x8x8 LED cube now available, by popular demand:

Step 1: What You Need

Picture of What You Need
First of all, you need quite a bit of time to solder together 64 leds ;)

Knowledge list:
  • Basic electronics and soldering skills
  • Know how to program an AVR microcontroller - I will not cover that in this instructable.

Component list:
  • Protoboard. The type with copper circles.
  • Atmel AVR Atmega16 microcontroller
  • Programmer to program the Atmega16
  • 64 Leds
  • 2 status leds. I used red and green. (optional)
  • Max232 rs-232 chip, or equivalent.
  • 16 resistors for leds. (100-400ohms) will get back to this.
  • 2x resistor 470 ohm. for status leds
  • 1x resistor 10k
  • 4x resistor 2.2k
  • 4x NPN transistor BC338 (or other transistor capable of switching 250-ish mA)
  • 1x 10uF capacitor
  • 1x 1000uF capacitor
  • 6x 0.1uF ceramic capacitor
  • 2x 22pF ceramic capacitor
  • 1x crystal 14.7456 MHz
  • 2x tactile button
  • optional pwr switch
  • connector for 12v power
  • optional connector for 5v power

Step 2: Multiplexing

Picture of Multiplexing

How to control 64 LEDs without using 64 individual wires? Multiplexing!

Running a wire to the anode of each led would obviously be impractical, and would look really bad.
One way to get around this, is to split the cube into 4 layers of 16x16 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.

If i only want to light up one led at a time, or only light up more than one layer at the same time.. this works fine.

However, if I also want to light up the bottom right corner in the front (3,3,0), I run into problems. When I supply GND to the lower layer and VCC to the front left column, I also light up the upper right led in the front (3,3,3), and the lower left LED in the back (0,0,0). This ghosting effect is impossible to workaround without adding 64 individual wires.

The way to work around it is to only light up one layer at a time, but do it so fast that the eye doesn't recognize that only one layer is lit at any time. This relies on a phenomenon called Persistence of vision.

Each layer is a 4x4 (16) image.
If we flash 4 16 led images one at a time, really fast, we get a 4x4x4 3d image!

Step 3: Making the Cube, Template

Picture of Making the Cube, Template
Soldering grids of 4x4 LEDs freehand would look terrible!
To get 4 perfect 4x4 grids of LEDs, we use a template to hold the them in place.

I wanted to make the cube as easy as possible to make, so I chose to use the LEDs own legs as much as possible. The distance between the lines in the grid was decided by the length of the LED legs. I found that 25mm (about an inch) was the optimal distance between each led (between the center of each led that is!) to enable soldering without adding or cutting wire.

  • Find a piece of wood large enough to make a 4x4 grid of 2,5cm on.
  • Draw up a 4x4 grid of lines.
  • Make dents in all the intersects with a center punch.
  • Find a drill bit that makes holes small enough so that the led will stay firmly in place, and big enough so that the led can easily be pulled out (without bending the wires..).
  • Drill the 16 holes.
  • Your ledcube template is done.

Step 4: Making the Cube, Solder the Layers

Picture of Making the Cube, Solder the Layers
We make the cube in 4 layers of 4x4 leds, then solder them together.

Create a layer:
  • Put in the LEDs along the back and along one side, and solder them together
  • Insert another row of LEDs and solder them together. Do one row at a time to leave place for the soldering iron!
  • Repeat the above step 2 more times.
  • add cross bracing in the front where the led rows are not connected.
  • Repeat 4 times.

Step 5: Making the Cube, Connecting the Layers

Picture of Making the Cube, Connecting the Layers

Now that we have those 4 layers, all we have to do is to solder them together.

Put one layer back in the template. This will be the top layer, so choose the prettiest one :)

Put another layer on top, and align one of the corners exactly 25mm (or whatever distance you used in your grid) above the first layer. This is the distance between the cathode wires.
Hold the corner in place with a helping hand and solder the corner anode of the first layer to the corner anode of the second layer. Do this for all the corners.

Check if the layers are perfectly aligned in all dimensions. If not bend a little to adjust. Or re-solder of it's the height distance that's off. When they are perfectly aligned, solder the remaining 12 anodes together.

Repeat 3 times.

Step 6: Choosing Resistor Values

Picture of Choosing Resistor Values

There are two things to keep in mind when choosing a resistor value for your leds.
1) The LEDs
2) The AVR

The AVR has a maximum combined current rating of 200 mA.
This gives us 12mA to work with per LED.

You also don't want to exceed the maximum current your leds are rated to.

I used 220 ohm resistors on my cube. This gave me about 12mA per led.

Step 7: The Controller

Picture of The Controller

The circuits controlling the led cube is described in the attached schematic image.

The RS-232 interface is optional. and can be omitted. That is IC2 and all the components connected to it. Future firmwares will enable PC communication..

Start by laying out all the components on you circuit board in a layout that enable all the components to connect with a minimal amount of wires. If everything fits, solder the circuit.

I won't give any more instructions on this, as the circuit probably will look very different from cube to cube, depending on the size of the circuit board etc..

Information on how to wire the cube to the controller circuit is in the next step.

Step 8: Wire Up the Cube

Picture of Wire Up the Cube

Pictures explain this better than words. Please see the pictures.

Step 9: Compile and Program

You now have a led cube. To make use of it, it needs some software.
I have made a driver for rendering a 3d data space on the cube, and functions to display some cool visual effects on the cube.

You can use my code, write your own or build on my code and make more effects.
If you make your own effects, please send me the code. I'm eager to see what you guys make!

To compile the program. Just open a command promt,
enter the directory with the source code
type "make" on the command line.

If you want to use an ATMega32 instead of the ATMega16, just change the mcu setting in the Makefile and recompile (type make). If you use the m32 and don't do this step, the cube won't boot properly (the red and green lights will keep blinking forever).

You should now have a file named main.hex in the source directory.
The next step will show you how to get that code into your cube.

Step 10: Program the Microcontroller

Picture of Program the Microcontroller
If you are experiencing problems with speed and/or some LEDs not lighting up. Please read this step carefully.

To program the microcontroller, I use avrdude and the USBTinyISP programmer.

My examples will be on an Ubuntu Linux system. The procedure should be pretty much identical on Windows, but I can't help you with that. If you use another programmer, read thet manual for that programmer and avrdude.

First off, Let's just see if we can make contact with the AVR.

Connect the programmer to your cube and your computer.

The command is "avrdude -c usbtiny -p m16", wherer -c specifies the programmer, and -p the AVR model. You can see the output in the images below.

Now, upload the firmware: "avrdude -c usbtiny -p m16 -U flash:w:main.hex".

By now, the cube should reboot and start doing stuff. It will be running at 1mhz (very slowly) using it's internal oscillator. And some of the leds won't work, because some GPIO ports are used for JTAG by default.

To enable the external oscillator and disable JTAG, we need to program the fuse bytes:
run "avrdude -c usbtiny -p m16 -U lfuse:w:0xef:m"
and "avrdude -c usbtiny -p m16 -U hfuse:w:0xc9:m".

Be carefull when doing this step! If you get it wrong, you can permanently destroy your microcontroller! If you are using another microcontroller than the ATMega16, be sure to read the datasheet carefully before changing the fuse bytes!

After writing the correct fuse bytes, the cube should reboot and start operating at regular speed with all leds operational.

Enjoy your new cube :D

Step 11: Go Large - 8x8x8

Picture of Go Large - 8x8x8
After making this quite fancy 4x4x4 cube, I have also made an enormous 8x8x8 cube. I'll make an instructable for that one when I have time. Meanwhile, see pictures :-)

You can find the 8x8x8 version here:

Please rate this instructable if you like it! :)


EsmileM (author)2017-09-27


Inventor17 (author)2017-09-20

Can I not use the voltage regulator and the Max232 chip. If I don't use them will the cube still work?

Inventor17 (author)2017-09-18

what are the black things below the board called? To keep it off the table.

Inventor17 (author)2017-09-17

how big is the protoboard?

3758 (author)2017-05-20

Tell me, please, the code is written in C or C++?

Steve25 (author)37582017-07-08

It is written in C

aneamţu (author)2014-07-20

I built my ledcube thanks to your awesome tutorial, but saw this "To compile the program, open a command prompt, enter the directory with the source code and type "make" on the command line. You should now have a file named main.hex in the source directory" I tried that with the source files and I get all kinds of errors. C:\WinAVR-20100110\xledcube>make

0 [main] sh 2156 sync_with_child: child 1572(0x14C) died before initializa

tion with status code 0xC0000142

670 [main] sh 2156 sync_with_child: *** child state waiting for longjmp

/usr/bin/sh: fork: Resource temporarily unavailable

-------- begin --------

avr-gcc (WinAVR 20100110) 4.3.3

Copyright (C) 2008 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO


Compiling: main.c

avr-gcc -c -mmcu=atmega16 -I. -gdwarf-2 -DF_CPU=14745600UL -Os -funsigned-char

-funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-

adhlns=main.lst -std=gnu99 -MD -MP -MF .dep/main.o.d main.c -o main.o

In file included from main.c:74:

draw.c: In function 'setplane':

draw.c:170: warning: comparison between pointer and integer

draw.c:170: warning: comparison with string literal results in unspecified behav


..... long list down. What is the problem ? I want to try this to remove some of the effects. I already uploaded the hex file but I want fewer effects.

DylanH103 (author)aneamţu2017-05-09

Having the same problem was this ever solved?

hey. can u email me the program?

dymo69 (author)2017-03-09

anyone have C code for cube

Steve25 (author)dymo692017-03-10

Download the file in step 9.

Steve25 (author)2017-03-06

chr why do you say in the code comments that the cube runs on 240 fps? In fact its running up to 1920 fps. The TCCR2 is set on a value of 5. This would make the prescale clock/128 instead of clock/1024. Not that it affects the cube... Just noticed it :P

yurka333 (author)2016-11-06

Anyone know what programm used to make scheme like in step 7?

Steve25 (author)yurka3332017-03-06

It's made in eagle

DylanC73 (author)yurka3332016-11-29
yurka333 (author)DylanC732016-11-30

Yeah, there's huge number of programms to draw such schemes, but I liked how it looks like in step 7 ;) But thanks anyway for reply.
If anyone know programm to draw exactly like in step 7 tell me ^^

MattS315 (author)2016-12-07

does anyone know how to conceal the board and make it look more clean and presentable?

Nice! Definitely gonna make it!

Adhyastha. MI (author)2014-12-25


rahul17797 (author)Adhyastha. MI2016-09-14

Hey do u have programming of 4*4*4 led cube than please send me on my e mail

xXL0rd0fCha0sXx (author)2016-06-15


I m new to microcontrollers.

I currently have an Arduino Uno, would I be able to use this for a 4x4x4 LED cube?

If so, could someone please provide a wiring diagram?

Thanks in advance!

IkhsanH1 (author)2016-05-08

what programming language are you using??

TranH2 (author)2016-05-02

có thể mua mạch điều khiển đó ở đâu

wmada (author)2015-11-29

anyone experienced to offer some insight? i ve built many using arduino but i ordered one online a kit one and it came wirh no instruction. it runs off a driver and has sound sensor anyone know how to build it

WhittlinThom (author)2015-11-22

I have been trying to find a tutorial for a bi-colored led cube. Do you have any idea where I could get some help with one in a 4x4x4? Thank you, Thom Mulford

Fezder made it! (author)2015-11-17

Right, so i placed RTC to show time, made enclosure from oak, finished with linseed oil, and placed mirror-plating as extra touch to create infinity-mirror effect, only in milder effect, it can be viewed in every direction

Fezder (author)Fezder2015-11-17

forgot to add, took hints/information from your bigger cube like that soldering jig, thanks!

GiovanniA5 (author)2015-11-02

Great project man!
Can u send me the code? "HEX"


TheKoobay. (author)2015-09-03

Hai haii..

I made led cube 3x3x3
Obstacles that arise is when
- 3x3 layer 1 __ Is correct (all live)
- 3x3 layer 2 __ Is correct (all live)
- 3x3 layer 3 __ Is correct (all live)

Why when I combine layer1, layer2, and layer3 (Many LED DEAD).

I want to know why many LED die ???

Thank you very much

dsahoo1 (author)2015-08-21

tell me how to generate code for 4*4*4 led cube.,.,

plz send me link for generationg code for AVR.

sudeep2896 (author)2015-08-15

can i use a bc548 instead of using bc 338 transistor

Aakash04 (author)2015-01-18

Hello, I'm a free user and i wanna make this project. It is showing 11steps, are they complete or should i turn to a paid user?
Please tell

MarkS13 (author)Aakash042015-08-06

There are only 11 steps, free uses can see all the steps and comments, but can not download the project as a pdf, support the site and other things.

SiddheshEM (author)2015-07-21

I am facing problem in compiling code . Which compiler or converter should be used to convert the above .c files to .hex files

SiddheshEM (author)2015-07-04

Is Willar programmer fine for Programming Atmega16??

ares (author)2015-06-27

I put the .hex file on the desktop. I got in command prompt this message:

error opening 4x4x4_ledcube.hex: no such file or directory

Whats the problem?

rachgaines (author)2015-05-30

I would really like to start this project; it looks so cool! Could I build the 8x8x8 with the Arduino Uno instead? It only has three ports so would it even be possible or would I only be able to build the 4x4x4 cube with the Arduino Uno? If I have to do the 4x4x4 cube, the wiring would probably be different and the code would remain the same though right?

dvberger (author)2015-05-27

Ungrounded layers sometimes light dimly:

I built a prototype of a 4x4x4 LED cube on 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. 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. net/net, I copied this design but hooked it up to an arduino

Anesa (author)2015-04-19

I have problem with the usbtinyisp. who can help me?

sonauk (author)Anesa2015-04-28

You need to install windows driver for your 'usbtinyisp' first.

Anesa (author)sonauk2015-05-07

I installed the driver and the usbtiny communicated with the chip. But when I try to setting the fuse, the programm tell me something like "change 0 with ... (y/n)". I write "n" and from this moment the usbtinyisp can't communicated (connection failed, rc=-1)

nounou.bedri (author)2015-03-17

i need to know how can i programme a cube led 4*4*4 without arduino !!!! plzzzzz

kou (author)2015-02-12

can you email me the program with "mikropascal pro" ?

marcin.kostyszyn (author)2014-11-12

Hi there, I want to make my LED Cube on STM32F4 Discovery board. It has Current Limit 150 mA and I have only 270 ohm resistors, which give

3V Ouput

11 mA per LED

177 mA when all 16 LEDs are ON. Will it damage my board?

Here is documentation link, p 77

P.S. Thanks for great instructable!

I made the cube with this board.

It won't damage the board. You will have only 150/16~9 mA per LED instead of 11 mA.

The side-effect is that one LED in layer will glow brighter then 16 in the same time.

P.S. sorry for my english.

sunnyt (author)2014-09-23

i want to make a 5*5*5 led cube.what changes should i consider??

bam500 (author)2014-09-20

Hello ! Thank you for this awesome instructable.
I made a mistake while programming the microcontroller.
I ran "avrdude -c usbtiny -p m16 -U lfuse:w:0xc9:m" instead of "avrdude -c usbtiny -p m16 - U hfuse:w:0xc9:m" (the difference is "lfuse" instead of "hfuse").
What's the command to reset the microcontroller ?
Thank you for your help.

akki5230 made it! (author)2014-09-18

Great Instructable!!!

fliberty made it! (author)2014-08-26

Wahoo! It's finally complete! One of my inner bottom LEDs just died on me though :( That will be fun to switch out.

This instructable was great!

About This Instructable




Bio: I like microcontrollers and LEDs :D
More by chr:Reverse Engineering: RGB LED Bulb with IR remoteReverse engineering: USB controlled home automation hackLED Cube 8x8x8
Add instructable to: