Introduction: LED Cube With Arduino and Custom PCB

This instructable details the design and building process for a 5 x 5 x 5 LED cube, controlled with an Arduino, which resides on a custom printed circuit board. 

Additional information, photos, and videos can be found on my website.

The finished product is shown in the video below:


Step 1: Design Concept and Materials

I have seen many designs for LED Cubes, and they all share the same problem:  How to control so many LEDs with so few pins.  Many designers choose to utilize shift registers, which uses a serial load with parallel output.  I was not to fond of this idea, primarily because of the time needed to shift all bits and the possible resulting trailing effect, so I started from my own drawing board, see attached.   

My design uses 5 x 3-8 line decoders (also known as DEMUX) to convert a 5-bit parallel binary output to a one-hot 25-bit parallel output, which drives the columns of LEDs.  "One-Hot" means that only one of the 25 output pins will be "hot" at any given moment.  If the five output pins of the arduino are: 01010, this is the number 10 in binary.  The decoders take interpret this signal and in turn power on output pin number 10 of the 25 columns (numbered 0-24).  See the attached design for illustration.

As many other LED cubes do, my design also uses NPN transistors to switch the cathodes of each plane of the cube.

My design also includes a custom designed Printed Circuit Board, to eliminate the many unsightly wires that would otherwise be needed.    


Part No.          Description                          Vendor             Quantity     Each        Total
74HC238       3-8 Decoder                        eBay                  5                $0.70        $3.50
LED                5mm Diffused Blue LED   eBay                 125            $0.09         $11.25
RES               150 Ohm Resistor                                         30              $0.05        $1.50
2N4401         NPN Transistor                    RadioShack    5                $0.20        $1.00
POT               10k Ohm Trim-Pot                RadioShack   1                 $1.49        $1.49
Arduino         Arduino                                   SparkFun        1                 $30.00      $30.00
PCB               PCB + Shipping                    AdvancedCircuits 1          $51.42      $51.42

Grand Total: $100.16

Second Thoughts:  Be sure to get one-HOT decoders, many will have every output high, but the one selected output LOW.  This is the opposite of what we want here.  Be CERTAIN to check the truth table in the  data sheet of whatever chip you purchase. 

Step 2: Cube Construction

The first step is to construct the cube of LEDs.  My LEDs were very cheap and the leads were incredibly short.  This is why I used additional wire, which worked out very nicely.

Firstly, make yourself a wooden jig to hold the LEDs when you solder.  I spaced mine 1" apart.  Solder all the CATHODES (-) together in the plane. 

Once you have all 5 planes done, its time to go up!  Use a 1" spacer between the planes as you solder.  Be sure you run enough wire vertically for all 5 planes, and then some extra.  

Done? Congratulations! You just made about 300 solder joints!

Second Thoughts:   Upon completion,  it appears that the Cube leans, and thats because it does.  When attaching the planes to the vertical wires, I attached to the same side of the LED lead each time.  To avoid this, alternate which side of the lead you attach to the vertical wire. 

Step 3: Prototype Circuit

Once you have the cube constructed, solder test leads to each anode and cathode set.  I used cat5 cable, purely because it is cheap and available.  If you don't have any spare wire, go to your local telephone system installation company and ask to buy their scrap, you can probably get it for less than 30 cents a foot.  

Assemble the circuit (as described in the pdf) on a bread board.  Choose a corner of the cube to be the origin, and connect that anode to output 0 from the decoders.  The next anode will be in the alleged X direction, and then you go to the next row down (output number 5) you will have moved in the alleged Y direction.  Don't forget resistors!  I used 150 Ohm resistors in series with each column (between the decoder and the column)

To wire up the cathodes, use the NPN transistors and switches to ground.  You need to use a resistor between the base pin and the output from the arduino.  If you have never used transistors before, they are fairly straightforward: for an NPN type, the two outer leads are like the two terminals of a simple switch.  The center lead is the signal that, when HIGH, completes the circuit.  Thus connect pin 1 to ground, pin 2 to arduino ouput, and pin 3 to the cathode plane of the cube.  

Step 4: Programming With Arduino

Once the Cube is wired up to your prototype circuit, write some test code!

One clever function I developed to efficiently realize the output to the decoders is documented below, and also found in the code attached.  This is where some bitwise black magic obviously occurs.

 * Displays the anode column with the given number value; [0, 24].
void displayNum(int num){
  //constrain the argument to be between 0 and 24 inclusive.
  num = constrain(num, 0, 24);

   * AND: selects the bit, the bit at weight will be 1 if the pin is to be high
   * >>: shifts the selected bit to the end of the word, making the value a 0 or 1
   * first result is lsb
   * digitalWrite: write the approptiate result (HIGH or LOW)
* to the appropriate decoder pin
for(int weight=1, pin=0; pin < DECODER_BITS; weight*=2, pin++)
digitalWrite(decoderPins[pin] ,(num & weight) >> pin);

//delay, this is the absoloute minimum time the light will be displayed.
//ensures adequate delay for decoders as well.

The rest of the code I used is attached here as well.  This is broken into 4 main pieces. 

     Contains all pins definitions, and arrays containing pins for swift iterations. 
     Contains a few basic "shapes" in the cube, for use in patterns. 
     Contains patterns which the cube can display.  Each is documented in the code, and can be seen in the video in the intro step of this instructable. 
     This is the final version of my code, and its setup() and loop() functions.  you will notice that I choose which pattern to display at reset based on the position of the potentiometer (discussed next step).  I would encourage a better way to change patterns, also discussed in the next step. 

Step 5: Add-ons

To make the LED Cube more functional as a standalone piece of decor, settings need to be adjustable on the fly, and not by re uploading code each time you want to change the pattern.

One add-on I used was a potentiometer, whose analog reading was directly related to the delay time of the animation, as seen in the video.

Second Thoughts:

Another intent I had was to use jumpers to select which pattern to display--this can be seen on the PCB design.  however, I never tested this concept, and forgot that a pin reading is unstable without a reference voltage.  If you try this, you will probably need a pull up resistor configuration.  Whatever you do, don't do what is shown on the PCB design, and do test it. 

Also, as cheap as they are, potentiometers are versatile, and a second one could easily be used as a pattern selector. 

Step 6: PCB Design

I designed this circuit and PCB in Eagle, which is free PCB design software, available at .  I have attached the eagle files for your reference or reuse, but as stated previously, some re-working my be desired.  

If you are new to PCB design, it is easy and fun!  One good tutorial can be found at the instructable titled "Turn your EAGLE schematic into a PCB" .

Second Thoughts:
One thing to watch out for when designing a PCB is the size of the drill holes.  Most parts in the library are good, but be sure to check wire connections, like those of the anode columns. 

Also, if you like the project, but not the cost of the professionally fabricated PCB, you could also easily create this on a perfboard , or even use a toner transfer do make your own PCB while still using Eagle .

EDIT:  The attached eagle files have been fixed for the jumper issue, they now jump to GND instead of VCC

Step 7: PCB Manufacture and Assembly

To send a design out for manufacture, you will first need to create a drill file and gerber files.  This area is not my specialty, but the instructable "Professional PCBs almost cheaper than making them at home" nails it, follow the instructions to a T and you will have no problems. 

EDIT: Due to a few requests, I have attached the gerber files needed by the manufacturer to this page.  Please notice that the issue with the jumpers has been fixed in this version. (they now jump to GND, which will work by using the arduino internal pull-up resistors.  

Finding a manufacturer:  
I got my PCB fabricated at Advanced Circuits , and here's why:
1.  US Based:  Don't get me wrong, I order TONS of components Hong Kong direct, the postman is used to seeing Chinese stamped padded envelopes in my box, but matters here is that when I am antsy for my board to arrive, I DON't have to wait three weeks for shipping!

2. $33 each. yup, just $33 per board for standard spec orders.  Whats the catch? Minimum order of 3, see below.

3. STUDENT DISCOUNT!  Advanced Circuits will let you order only one of their $33 each special for students!

4. Free DFM check, basically it makes sure your drill and gerber files are correct before you give them any money.

5.  Free surprise with each order, its popin good ;)

Begin soldering components with the lowest profile, meaning height.  Start with resistors, then the IC sockets, ... , and finish with the cube itself last. 

I used all through hole components, so assembly is pretty straightforward.  If you've never soldered on a PCB before, here are the keys:

1.  Use a good, clean iron.  Clean your tip with tip tinner and a wet sponge.
2.  Heat the PART*.
3.  Apply solder to the BASE OF THE HOLE.
4.  Allow solder to seep into hole before removing heat. (about a half second)

*Be cautious not to overheat components containing semiconductors, as they are easily damaged by heat.  I used sockets for all DIP chips (decoders)

Step 8: Done!

Once your custom board is assembled, test it out!  Upload the code and snap on your arduino. 

For more pictures, descriptive videos, and more projects, check out my website at:

Comments? Questions? Post-em!

Second Thoughts:
If the lights don't act as you anticipate, first check that your decoder pins are placed properly, as indicated in the PDF of step 1.  Swapping bits will mess it up big time. 


ArduinoUser1337 made it!(author)2017-02-11

Can somebody tell me where I can find the PDF that covers the whole building process?

MichaelH169 made it!(author)2016-04-03

hi, i want to ask about your PCB eagle... it is layer which connected with the column.. i can't understand that hub...

may can you explain that PCB?

thank you.. i'm from indo..

JacksonY made it!(author)2015-10-05

HI, I want to ask whether which type of arduino board that you have it Arduino UNO???

CraigH5 made it!(author)2015-08-14

I have wrote an instructable on the cube I built based on yours and I have given full credit to you for the idea, the design of the circuit and the code... once again, many thanks for giving me the inspiration to make this a possibility!

CraigH5 made it!(author)2015-06-18

Ignore that one lol.. just noticed that it is the way it is drawn... I do have a problem tho.. If I have the cube on random blink, all of the bulbs light up apart from 2 columns but some bulbs are really dull as well... On the other modes, it looks as tho 4 of the columns are not lighting but 2 of them are just ridiculously dull. I have tried a new 74HC238 and new resistors but it is still doing the same.. if I short power over the planes I can get the bulbs to light up so I am happy there are no shorts on the actual cube... Any ideas?

shashi.gupta.39108297 made it!(author)2015-04-19

dude ... I built my led 5x5x5 led cube .. but when I uploaded the code many compiling error found but still trying .dude can you help me please send the source code for 5x5x5 led cube at

please because I am exciting to see my led cube......

CraigH5 made it!(author)2015-02-11


I have built the PCB and I am in the process of constructing the LED part but I have a question for anyone that has already built this project...

I am new to the code and from what I can tell the display depends on where the POT is positioned as the Arduino is powered up (correct me if I am wrong) so my question is... How can I tell what program will start depending on where the pot is and can I change it to use the jumpers for selection. I have fitted Dip switches to my board instead of jumper pins as I had one available.

From what I understand an analogue reading is between 0 and 254 so is it possible to have a kind of 'If pin1 has value greater than * and pin 2 has value greater than * then display program 1' type of thing or am I barking up the wrong tree here?

Thanks in advance for any replies I get.


ajmontag made it!(author)2015-02-11

If you look at the getPattern function, you'll see that it reads the pot and divides that by 255. Since analogRead will return a value from 0 to 1023, getPattern will return 0 through 3.

If you think about the full scale of the pot, and divide that into four segments, each segment will give you a different on pattern on boot up.

You can change the code to have different ways to get the pattern, so you can add more patterns, or make it easier to select.

CraigH5 made it!(author)2015-02-11

Thanks for the reply... I now understand a bit better how it works :)

I am about to start the LED part this weekend (hopefully) so fingers crossed I have assembled the circuitry correctly. :)

Thanks again for the awesome instructable giving me the inspiration to try it myself!

delliark made it!(author)2015-01-11

do you have script code for 5x5x5 led cube, i can't make the code i think it's so difficult for me, can you help me? please

i'm from indonesia thanks

mstoetz1 made it!(author)2011-02-10

I'm willing to depart with 5 or 6 of the PCB's I got made. The cost ended up being $206.08 ($15.50 + $29 shipping + $22.08 taxes x 10 boards) for me to get them.

The choices I had at order time was around 12 with 10 day turn around, or 15.50 with 6 day turn around. I would have been good with the 10 day, except the place I ordered from (Ottawa Canada) celebrated Chinese New Year and shut down for 10 days over that time, so I decided to do the $155.00 / 10 board plan.

I have Andrew to thank for providing this instructable, and the gerber files. He did all the work.. thank you Andrew!! PS: your name is on my boards, so you're going to be famous ;)

I've attached a pic of the one I've started. To be honest, I sort of "whipped it together". The next one I think I'll spend more time making the cube perfectly straight.

judas79 made it!(author)2014-07-30

I realise this is an old post, but do you have a pcb for sale still? I made a 3x3x3 a few years ago and would like to build something more interesting and neater!

mstoetz1 made it!(author)2014-07-31


Yes I think I do have a few left... as well as many of the parts. If you're interested, please let me know your shipping address?

mstoetz1 made it!(author)2011-02-10

Here is the board so far... I am waiting on the resistors still though.

mstoetz1 made it!(author)2011-02-22

We've had the cube up and running now, and since my room mate is much better at c++, she's working the code to do some different patterns.

She seems to be catching on fast, and the only issue we've noticed is with "some" patterns, some incorrect LED's are very dim, but being lit. Its a bit weird in that if you light a vertical set of 25 LED's and go left to right, it works fine, but up and down had a this issue.

We can share the code of different patterns with anyone who is willing to work together in coming up with some cool patterns.

mstoetz1 made it!(author)2011-03-13

These are some examples of how I created loops for the LED leads that helped with the soldering. The first LED cube I did not using these loops was much more difficult and took longer.

lostalaska made it!(author)2011-06-28

I know this was posted a while ago, but still wanted to say thanks! I was wondering the same thing after doing a 3x3x3 cube where I used a jig, but soldering the levels together I ended up bending the columns a little too much and they weren't all perfectly square when I was done. This was exactly what I was looking for. I picked up some 18 gauge, 16 gauge and 14 gauge solid core wire to try and figure out what the smallest size gauge I can use and still keep a fairly rigid structure. I eventually want to get up to an 8x8x8, but not sure about the learning curve for using a different type of controller and programming it.

Gonna test it out doing a 4x4x4 cube as I also just need a lot more practice with a soldering iron and from the reading I've done so far the 4x4x4 can be done with an Arduino basically the same way I did my 3x3x3 with a few NPN transistors. I also picked up the parts for this 5x5x5 cube, but I'm a total noob to digital electronics so baby steps...

If you do end up reading this, what gauge and type of wire did you use to build the grid?

ajmontag made it!(author)2011-06-28

If you look at step 2, you'll see that my wire was 20ga galvanized steel

lostalaska made it!(author)2011-06-29

Ah, steel is probably the way to go, I started in last night on a 4cubed and was using 18gauge copper, which seemed to work alright, but steel would probably be less malleable and be less likely to get bent accidently. I'll have to check some hardware shops around Juneau and see what they got. One of the hardware stores is bound to have something like this.

I picked up all the parts to follow this instructables 5x5x5, but didn't want to start it until I figured out how to make a very square and properly lined up cube. With my soldering skills getting better with every attempt and using a grid system as mstoetz showed in the above post I'm pretty sure I'm close to trying a 5x5x5 cube.

mstoetz1 made it!(author)2011-06-28

Here is the wire I used for the LED cube. I think I purchased it from Michaels.. where you can get an assortment of craft supplies.

lostalaska made it!(author)2011-06-28

Thanks for the quick response, I'll have to swing by my towns two small craft stores and see what they have. Living up in Juneau, Alaska my local options are _very_ limited. The heaver gauge solid wire I picked up had a plastic sheath on it and I found it at a boat shop in the wiring section, so I was trying to figure out a way to strip off all of it without gouging the copper horribly.

I ordered 200 diffused green T1 3/4 (5mm?) LED's from Jameco that I'll be using to test this grid system out with a simple 4cube this weekend after I've tinkered with the code for my current 3cube. Thanks again!

mstoetz1 made it!(author)2011-06-28

I bought all my LEDs from Ebay... these were the two types I used in cubes so far:

5mm straw hat Green LED Wide Angle 14000 MCD (very bright)

5mm Blue Diffused LED 5000 MCD

I paid like $15 for 300 LEDs

mstoetz1 made it!(author)2011-03-22

So far I tried some really bright green LEDs, and diffused blue LEDs.

Both look pretty cool.

Here's some video samples of the code my room mate did. She is going to add more letters, and make it more organized later.

ajmontag made it!(author)2011-02-22

That is an issue with a mismatched delay time of the NPN (cathode) switching transistors and the propagation delay of the 3-8 decoders. Have you taken any courses in digital logic design? Here is the gist:

The signal to the decoders must pass through many transistors before it comes out the other side, whereas the cathodes are on a single transistor. This _may_ be able to be fixed by adding a very minute delay between the decoder and NPN signals, But i have not tried this.

I notice this primarily on the squares animation, when there are two LEDs instead of one in the center.


mstoetz1 made it!(author)2011-02-22

Thanks for the info Andrew. we'll take a look at the timing.


seatra made it!(author)2011-03-22

Do you still have any boards left for sale? If so, are the jumpers corrected (to GND)? Thanks.

mstoetz1 made it!(author)2011-03-22

Hi, yes.. I built three cubes.. I may do one more using different LED's.. so I'll have 6 boards left if you or anyone wants them. (at cost).

seatra made it!(author)2011-03-22

I am interested in one. Email me at with the details. Thanks.

mstoetz1 made it!(author)2011-03-22

I'm not actually using the jumpers... we're just changing the code.

Btw... if anyone has done some additional code, let me know. I'll share what we've done.

%E6%B5%A9%E6%9D%8E made it!(author)2013-12-15

Hi ajmontag.
I finish the hardware but I don't know how to program it.
may I ask you for a code for LED CUBE code sample
can you mail to

npedrazzoli made it!(author)2013-12-07

you can send me the program that is to be loaded on the arduino1 by email?

Tuffy_DK made it!(author)2011-10-16

Hi ajmontag.

I've tried to build your cube 5x5x5x by using your schematics (Cube.sch), but its not working.

I think there is something wrong with your layout (cube.sch). Can you please check it again??


SaurIMX made it!(author)2013-10-04

can you please tell me how to change the patterns?

ajmontag made it!(author)2011-10-16

I am quite positive the schematic is good, since I made a PCB from it and it works too. Check your wiring and let me know if you have any questions.

Tuffy_DK made it!(author)2011-10-17

Hi ajmontag.

I've now tested all my wireing with an ohm meter and all wires are ok - I started all over on my breadboard and finished up with the same thing as yesterday... Nothing.. :-(

But then I removed the GND wireing (on pin 4 and 5) from the 74HC238 (V1 to V5) and then it seems to work (LEDS are flashing on and off).

Is it a mistake to wire pin 4 and 5 to GND???

Kindly Regards

ajmontag made it!(author)2011-10-17

That should not be the problem, If you have checked everything over I would pull everything off the breadboard and start over. You could also unit test a single decoder (74-238) to make sure that is working properly

Tuffy_DK made it!(author)2011-10-17

Hi ajmontag.

I'll check all my wiring, and get back to you.. Perhaps there are one broken wire (on the breadboard)...



hassantahir222 made it!(author)2013-09-06

can 74138 decoder be used here instead of 74238 ???

i have 74138 x 5 decoders but when i place them in socket all the leds in a layer glow rather than 1 by 1
any idea about it that how to solve this problem ??

SaurIMX made it!(author)2013-09-03

can i use atmega8 with arduino bootloader instead of atmega328?
and could you please explain how you placed those switches?

SaurIMX made it!(author)2013-08-18

Any other alternative for 74HC238?

ajmontag made it!(author)2013-08-18

a MAX7221 or similar would be a better solution. That is a serial constant current source/sink. You should be able to do the whole cube with just one or two of those.

TheNickmaster21 made it!(author)2013-07-28

Why did you make the Arduino the brain when you could have easily just put an Atmega chip instead?

Geekaton made it!(author)2013-03-07

i am 15 and have made my own LED cube, heres a video of how I made it:
let me know if its helpful!

AmalZone made it!(author)2013-02-27

Dear Sir,

We are a marketing company in Saudi Arabia . We are interested in buying a customized LED cube for a project that we are handling now. The LED has to be one meter in length and one meter in depth and 2.5 meters in height.

Please let us know if it is possible to build it and give us a quotation on that.

Amal Alsayegh
Marketing and PR rep.
Zone Arabia

ajmontag made it!(author)2013-02-27

Thank you for the offer, but I am not interested at this time. There are many others online who have made a similar device that you can ask.

yonch made it!(author)2012-08-26

Can it work with Arduino Uno?

ajmontag made it!(author)2012-08-26

yes, they should be pin-compatible.

yonch made it!(author)2012-07-21

I think I did it wrong. Is the power to the LED's coming from the column or plane? I connected the short pin of the led to the plane and the long to the column.

ajmontag made it!(author)2012-07-31

Each plane is for negative, each column is for positive.

yonch made it!(author)2012-08-12

I'm very confused with the negative positive. According to the led pinout below, which pin is connected to the plane and which to the column?

About This Instructable




More by ajmontag:Compost Bin - Low Cost, Easy, and ModularOverhead desktop tripodOrganize your IC's, Microcontrollers, and Misc Components
Add instructable to: