Introduction: How to Build an 8x8x8 LED Cube and Control It With an Arduino

There are a lot of LED cubes on Instructables, so why do another? Most are for small cubes consisting of 27 or 64 LEDs, rarely larger since they are limited to the number of outputs available on the microcontroller. This cube will be 512 LEDs, and will only need 11 output wires from the Arduino. How is this possible? By using the Allegro Microsystems A6276EA LED driver.

I'll show you how I made the cube itself, the controller board, and finally the code to make it shine.


Step 1: Materials

All parts you'll need to build the cube:

1 Arduino/Freeduino with Atmega168 or higher chip
512 LEDs, size and color are up to you, I used 3mm red
4 A6276EA LED driver chips from Allegro
8 NPN transistors to control the voltage flow, I used the BDX53B Darlington transistor
4 1000 ohm resistors, 1/4 watt or higher
12 560 ohm resistors, 1/4 watt or higher
1 330uF electrolytic capacitor
4 24 pin IC socket
9 16 pin IC sockets
4"x4" (or larger) piece of perfboard to hold all the parts,
An old computer fan
An old floppy controller cable
An old computer power supply
A lot of hookup wire, solder, soldering iron, flux, anything else to
make your life easier while making this.
7"x7" (or larger) piece of wood used to make the LED soldering jig
A nice case to display your finished cube

My Arduino/Freeduino of choice is the Bare Bones Board (BBB) from www.moderndevice.com. The LEDs were purchased off eBay and cost $23 for 1000 LEDs shipped from China. The remaining electronics were purchased from Newark Electronics (www.newark.com) and should only cost around $25. If you have to buy everything, this project should only cost around $100.

I have a lot of old computer equipment so those parts came off the scrap heap.

Step 2: Assemble the Layers

How to make 1 layer (64 LEDs) of this 512 LED cube:

The LEDs I bought were 3mm in diameter. I decided to use small LEDs to cut down cost and to make the final size of the cube small enough to sit on my desk or shelf without completely taking over the desk or shelf.

I drew an 8x8 grid with approximately .6 inches between lines. This gave me a cube size around 4.25 inches per side. Drill 3mm holes where the lines meet to make a jig that will hold the LEDs as you solder each layer.

The A6276EA is a current sink device. This means it provides a path to ground rather than a path to source voltage. You will need to build the cube in common anode configuration. Most cubes are built as common cathode.

The long side of the LED is generally the anode, check yours to make sure. The first thing I did was test every LED. Yes it's a long and boring process and you can skip it if you like. I would rather spend the time to test the LEDs than find a dead spot in my cube after it was assembled. I found 1 dead LED out of the 1000. Not bad.

Cut 11 pieces of solid, non-insulated hook up wire to 5 inches. Place 1 LED into each end of a row in your jig and then solder the wire to each anode. Now place the remaining 6 LEDs into the row and solder those anodes to the wire. This can be vertically or horizontally, it doesn't matter as long as you do all the layers the same way. As you finish each row, trim the excess lead from the anodes. I left around 1/8".

Repeat until you've finished all 8 rows. Now solder 3 pieces of hook up wire across the rows you just made to connect them all into a single piece. I then tested the layer by attaching 5 volts to the
hook up wire lattice through a resistor and touched the ground lead to each cathode. Replace any LEDs that don't light.

Carefully remove the layer from the jig and set it aside. If you bend the wires, don't worry, just straighten them out as best you can. It's very easy to bend. As you can tell from my pictures, I had a lot of bent wires.

Congratulations, you're 1/8 done. Make 7 more layers.

OPTIONAL: To make soldering the layers together (Step 3) easier, while each subsequent layer is still in the jig bend the top quarter inch of the cathode forward 45 to 90 degrees. This will allow the
lead to reach around the LED it is connecting to and will make soldering much easier. Don't do this to your first layer, we'll declare that one is the bottom layer and the leads need to be straight.

Step 3: Assemble the Cube

How to solder all the layers together to make a cube:

The hard part is almost over. Now, carefully place one layer back into the jig, but don't use too much pressure, we want to be able to remove it without bending it. This first layer is the top face of the cube. Place another layer on top of the first one , line up the leads and start soldering. I found it easiest to do corners first, then outside edge, then inside rows.

Keep adding layers until you are done. If you pre-bent the leads then make sure to save the layer with straight leads for last. It is the bottom.

I had a little too much space between each layer so I didn't quite get a cube shape. Not a big deal, I can live with it.

Step 4: Building the Controller Board

How to build the controller board and attach it to your Arduino:

Follow the schematic and build the board however you choose. I placed the controller chips in the center of the board and use the left side to hold the transistors that control the current to each layer of the cube, and used the right side to hold the connectors that go from the controller chips to the cathodes of the LED columns.

I found an old 40mm computer fan with a female molex connector to plug it into a computer power supply. This was perfect. A small amount of air flow across the chip is useful and I now have an easy way to provide 5 volts to the controller chips and the Arduino itself.

On the schematic, RC is the current limiting resistor for all the LEDs connected to each A6276EA. I used 1000 ohms because it provides 5 milliamps to the LED, enough to light it. I'm using High Brightness, not Super Brite LEDs, so current drain is lower. If all 8 LEDs in a column are lit at once, it's only 40 milliamps. Each output of the A6276EA can handle 90 milliamps so I am well within range.

RL is the resistor connected to the logic or signal leads. The actual value is not very important as long as it exists and is not too large. I'm using 560 ohms because I had a bunch of them available.

I used a power transistor capable of handling up to 6 amps to control the current going to each layer of the cube. This is overkill for this project, as each layer of the cube will only draw 320 milliamps with all the LEDs lit. I wanted room to grow and might use the controller board for something bigger later. Use whatever size transistor fits your needs.

The 330 uF capacitor across the voltage source is there to help smooth out any minor voltage fluctuations. Since I'm using an old computer power supply, this is not necessary, but I left it in just in case someone wants to use a 5 volt wall adapter to power their cube.

Each A6276EA controller chip has 16 outputs. I didn't have any other suitable connector so I soldered leads to some 16 pin IC sockets and will use those to connect the controller board to the cube. I also cut an IC socket in half and used it to connect the 8 wires that connect the transistors to the layers of the cube.

I cut about 5 inches off the end of an old floppy cable to use as the connector for the Arduino. The floppy cable is 2 rows of 20 pins, the bare Bones Board has 18 pins. This is a very cheap way (free) to connect the Arduino to the board. I pulled the ribbon cable apart in groups of 2 wires, stripped the ends and soldered them together. This allows you to plug the Arduino into either row of the connector. Follow the schematic and solder the connector into place. Don't forget to solder the 5 volt and ground leads for the connector to provide power to the Arduino.

I intend to use this controller board for other projects so the modular design works nicely for me. If you want to hard-wire the connections, that is fine.

Step 5: Build the Display Case

Make your final product look nice:

I found this wooden chest at Hobby Lobby for $4 and thought it would be perfect since it has space inside to hold all the wire plus it looks nice. I stained this one red, same stain I used on my computer desk so they match.

Draw a grid on top the same size as the grid used for the soldering jig (.6 inches between the lines). Drill holes to allow the leads through the top, and drill another hole behind the grid for the layer/plane wires (from the transistors in Step 4). I learned the hard way that trying to line up 64 leads to go through small holes is very difficult. I finally decided to re-drill all the holes a little larger to make the process go quicker. I ended up using around a .2 drill bit.

Now that the cube is sitting on top of the display, bend the corner leads so the cube will stay in place as you attach the wires. Make sure you attach all the wires in the correct order.

1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64

And connect the wires between the layers (labeled 'planes' on the schematic) and the transistors. The transistor on Arduino pin 6 is the top layer of the cube.

If you get the wires wrong, it is somewhat correctable within the code, but it may require a lot of work, so try to get them in the right order.

Okay, everything's built and ready to go, let's get some code and try it out.

Step 6: Code

The code for this cube is done differently than most, I'll explain how to adapt.

Most cube code uses direct writes to the columns. The code says that Column X needs to be lit so give it some juice and we're done. That doesn't work when using controller chips.

The controller chips use 4 wires to talk to the Arduino: SPI-in, Clock, Latch, and Enable. I grounded the Enable pin (pin 21) through a resistor (RL) so output is always enabled. I never used the Enable so I took it out of the code. SPI-in is the data in from the Arduino, Clock is a timing signal between the two while they talk, and Latch tells the controller it's time to accept new data.

Each output for each chip is controlled by a 16 bit binary number. For example; sending 1010101010101010 to the controller would cause every other LED on the controller to light. Your code needs to run through everything needed for a display and build that binary number, then send it to the chip. It's easier than it sounds. Technically it's a bunch of bitwise addition, but I'm lousy at bitwise math so I do everything in decimal.

Decimal for the first 16 bits are as follows:
1 << 0 == 1
1 << 1 == 2
1 << 2 == 4
1 << 3 == 8
1 << 4 == 16
1 << 5 == 32
1 << 6 == 64
1 << 7 == 128
1 << 8 == 256
1 << 9 == 512
1 << 10 == 1024
1 << 11 == 2048
1 << 12 == 4096
1 << 13 == 8192
1 << 14 == 16384
1 << 15 == 32768

This means if you want to light up outputs 2 and 10, you add the decimals (2 and 512) together to get 514. Send 514 to the controller and outputs 2 and 10 will light.

But we have more than 16 LEDs so it gets slightly more difficult. We need to build display information for 4 chips. Which is as easy as building it for 1, just do it 3 more times. I use a global variable array to hold the control codes. It's just easier that way.

Once you have all 4 display codes ready to send, drop the latch (set it to LOW) and start sending the codes. You need to send the last one first. Send the codes for chip 4, then 3, then 2, then 1, then set the Latch to HIGH again. Since the Enable pin is always connected to ground, the display is changed immediately.

Most cube code I've seen on Instructables, and the web in general, consists of a giant block of code set to perform a pre-set animation. That works fine for smaller cubes but needing to store, read, and send 512 bits of binary every time you want to change the display takes up a lot of memory. The Arduino couldn't handle more than a few frames. So I wrote some simple functions to show the cube in action that rely on calculation rather than pre-set animations. I included a small animation to show how it is done, but I'll leave it to you to build your own displays.

cube8x8x8.pde is the Arduino code. I plan to continue adding functions to the code and will update the program periodically.

matrix8x8.pde is a program in Processing to build your own displays. The first number given goes into pattern1[], second into pattern2[], etc.

The datasheet for the A6276EA is available at:
http://www.allegromicro.com/en/Products/Part_Numbers/6276/6276.pdf

Step 7: Display Your Handiwork

You're done, now it's time to enjoy your cube.



As you can see, my cube came out a little crooked. I'm not very keen on building another one though so I'll live with it being crooked. I have a couple dead spots that I need to look into. It might be a bad connection, or I might need a new controller chip.

I hope this Instructable inspires you to build your own cube, or some other LED project using the A6276AE. Post a link in the comments if you build one.

I've been trying to decide where to go from here. The controller board will also control a 4x4x4 RGB cube, so that's a possibility. I think it'd be neat to do a sphere and the way I have the code written, it wouldn't be too difficult to do.

Comments

author
Mettu GouthamR (author)2016-09-27

Hello
I have made the led cube using Micro controller and using hc164 shift register. Cam any one help me with the code.? Please can u send me the code. It would be so helpful..

author
VictorE9 (author)2016-02-26

hello, i tried to make your proect and im done making the cube and the schematic.
i tried to upload your code but it doesnt compile. im getting a error message:stray '#' in program. how to solve this?

author
R- (author)VictorE92016-03-09

The code was written with on an old version of the arduino IDE, beta 18 or 19 IIRC. I know there were some changes with the 1.x release and some sketches no longer compile. My suggestion is get one of the beta version and try compiling using that. It's been 6 years since I last worked on this, I couldn't tell what needs to change to fix it for the 1.x IDE.

author
VictorE9 (author)R-2016-03-20

hey, we tried the cube8x8x8 program and it worked. but your code and the pin configuration from the datasheet is not matched from whats written in the code.
i have another question, me and my friend tried to understand how the code works.
we want to light 1 led only, what should we input in the shiftregister to light 1 LED. int x = 0B0000000000000001? can you give me a short code for lighting a 1piece of LED.

we really need your help. thanks!
nice project btw. :)

author
VictorE9 (author)R-2016-03-20

hey, we tried the cube8x8x8 program and it worked. but your code and the pin configuration from the datasheet is not matched from whats written in the code.
i have another question, me and my friend tried to understand how the code works.
we want to light 1 led only, what should we input in the shiftregister to light 1 LED. int x = 0B0000000000000001? can you give me a short code for lighting a 1piece of LED.

we really need your help. thanks!
nice project btw. :)

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
Yonatan24 (author)sanuje2015-11-20

Did you notice that you sent this message like 10 times?

author
Yonatan24 (author)2015-11-20

Hi, I've added your project to the "A Collection of WAAAY To Many 8X8X8 RGB LED Cubes!" Collection

This is the link If you are interested:

https://www.instructables.com/id/A-Collection-of-WA...

author
hieden.deep (author)2015-04-02

Plz sen me 8x8x8 cubs code

my email id is ddgkcem@gmail.com

plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

author
SuperTech-IT made it! (author)2015-03-26

My cube (I make PC Boards for this project, and have an assembly method that makes near perfect looking cubes)

I also do an RGB cube

CIMG2875-2.jpgRAMP 1.0E Rev.4.jpg
author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
sanuje (author)2014-12-13

I COMMON ALL THE ANODE AND HOW TO CONFIGURE CATHODE TO ON LED IN 8X8 LED CUBE

author
susan.mcraetharp (author)2014-12-07

Many thanks - I did a circular 8x8x8 ( for a decorated wine bottle contest) using 74HC 595 and your code worked first try. I was very happy as i am too old to learn a new language. Plug and play or cry is my way of doing this stuff.

Rod

author
Hayawatta (author)2014-05-16

What about a 8x8x8 / 24V / 20W colored bulb lights? It's possible?

author
SuperTech-IT (author)Hayawatta2014-05-19

You would obviously need to make a driver board, likely with 64 opto-isolators and 64 mosfets with another 8 even higher power mosfets for the layer selects.

CAN it be done? Sure. But it will cost quite a bit, and be a lot more work.

author
brujah1980 (author)2014-02-04

here are some 10mm ones that worked

http://www.alibaba.com/product-gs/303796175/Factory_directly_30_off_10mm_round.html

author
SuperTech-IT (author)2013-09-01

This guy is using a completely different approach to the controller, but the cube assembly is the same. If you want to build this, but want the cube to look a little neater, check out my instructable.
https://www.instructables.com/id/CHRs-8X8X8-LED-Cube-Revisited-with-improvements/

F
ollowing my assembly method, the cubes tend to come out looking like this.

CIMG2073.JPGCIMG2072.JPGCIMG2092.JPG
author
BMC6765 (author)2012-12-21

Ok thanks alot

author
BMC6765 (author)2012-12-17

Also i was wondering why you prefer the bare bones board over the other arduinos

author
R- (author)BMC67652012-12-20

they're cheaper...$15 vs $30 each.

author
BMC6765 (author)2012-12-15

And also what are you useing for the hook up wire?

author
R- (author)BMC67652012-12-20

colored pairs from cat5 networking cable

author
BMC6765 (author)2012-12-15

will the Arduino UNO with ATMega8U20 chip work for this?

author
R- (author)BMC67652012-12-20

probably, I don't own an Uno but i don't think the pin out was changed. Load the software and see if it compiles.

author
BMC6765 (author)2012-12-16

hi. Im going to be attempting this soon and you have the best indestructible for what i want to do but i have a few questions. Will the arduino UNO work the same as what you are useing?

author
megaduty (author)2012-02-27

Well done R-!

author
William Ackley (author)2012-02-08

I applude your fantasitic effort! I have built several 4x4x4 and they are so hard to get square! I can only imagine what a n 8x8x8 must be like, I think no Matter WHAT anybody else says YOU ARE A WINNER to the max!

By Hawkings chair it was a fine accomplishment.

Good show,
Villiis Iohnes ab Oakmeadow.

author
jonodan (author)2011-12-14

Oh and thanks to R- for getting the mind cogs turning :)

author
fryddog (author)2011-10-03

Your tutorial looks pretty awesome so far. But before I give it a go, do you know what I can use instead of the led drivers. They appear to be discontinued everywhere.

author
mickjc75 (author)fryddog2011-11-20

Check out the TPIC6B595, these are similar (Hi current sink capability, output latch ect..) only they do not have constant current output so you will need series resistance on each column. They are commonly used in LED moving message displays.

author
pfred2 (author)2011-09-28

Intelligent build. Well documented. I have to give you a patch!

Now I am wondering what this all would have be like built it into an infinity mirror.

author
bibor168 (author)2011-08-14

Thanks for the detailed instruction on how to build an LED cube. I eventually managed to build one of these things my own and it works fantastic. Thanks alot again. I used eight 8bit shift registers and changed the code a little, but in the end it works like your prototype does.

author
kully3xf (author)2011-05-29

Hey! I'm workin on this project and i have everything assembled and finished, but when i send the code to the arduino it completes but the cube just stays lit up. every led is lit no matter what code i run to the arduino any idea what might be wrong?!?

author
Mechtek (author)2011-02-25

Is it possible to light one led at a time with this cube?

author
raaymaan (author)2011-02-03

This looks really nice, well done.

Just been skimming through and I wondered why there are two codes? Do they both go to the arduino consecutively??

author
raaymaan (author)raaymaan2011-02-07

Ok so I figured it out! Matrix.pde wouldn't verify with arduino but it will with a program called 'Processing'. It looks identical to the arduino GUI but I cannot state the major differences. http://processing.org/download/

Compile matrix.pde for a very easy way of making your own animations!

author
prcrow (author)2011-01-09

What are the 9 - 16 pin IC sockets used for?? I can't seem to find them on the circuit diagram. I assume it is used to connect to the leds,but not sure how that works.

Another comment they are discontinuing the A6276EA chip, it looks as if the TB62706BN/BF chip is a suitable replacement., do you see anything wrong with using it?

author
Piplx_22 (author)2010-10-24

Gday,

Just wondering, a few people have asked about which NPN transistors to get... there are so many options, just wanted to get the correct ones (newark part# maybe??)

Also - I bought 1000x 3mm Blue LEDs from ebay. They are 10000 MCD, 465-470 NM, 3.4-3.6v. Do I need to adjust anything to use these LEDs?

Cheers,
Pip

author
R- (author)Piplx_222010-12-08

I'd decrease the value RC from 1000, but don't go below 500 ohms. With all 8 layers lit, a value below 500 ohms will draw more power through the LED driver chips than they are rated to handle.

Transistors were BDX53B, but any NPN transistor would do.

author
ghostunit12 (author)2010-01-08

 Hi, could you tell me what are the blue wires coming out of the arduino for?

author
R- (author)ghostunit122010-12-08

They are the triggers from the individual layers. They go from the arduino to the power transistors.

About This Instructable

157,988views

107favorites

License:

More by R-:How to build an 8x8x8 LED cube and control it with an Arduino
Add instructable to: