I'll show you how I made the cube itself, the controller board, and finally the code to make it shine.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
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:
Step 7: Display Your Handiwork
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.
Participated in the
Get the LED Out! Contest
1 Person Made This Project!
SuperTech-IT made it!