Instructables
Picture of 4x4x4 RGB LED Cube
P1020672 b.jpg
P1020669 B.jpg
P1020682 b.jpg
P1020625.JPG
P1020676 b.jpg
A while ago, when I first started using Arduino, my first project was a 4x4x4 LED cube, I built it from a Guide I found here in Instructables, I didn't know anything about programming, and little about electronics, yet I was able to build it and make it work, I didn't know how it worked but it did!
That success made me like this page a lot and also made me want to make guides like that one, well documented and properly explained, enabling people to make cool things, at first without them knowing how they work, and from there, from a working piece, start learning and understanding how it works.












note: the last 2 videos are not from my cube, but it works in the same way and gives the same result.

Step 1: Materials

Picture of Materials
For the most basic cube you will need;
  • 1x Atmega328 (With arduino Optiboot bootloader)
  • 3x TLC5940
  • 4x P-Channel MOSFETs
  • 3x 4K7 Resistors
  • 3x 16 pin Male and Female headers
  • 1x 4 pin Male and female header
  • 1x 28pin IC socket
  • 1x 1000uf 10v capacitor
  • 1x 0.1 uf ceramic capacitor
  • 2x 22pf capacitors
  • 1x 16Mhz crystal oscillator
  • 64x RGB common ANODE LEDs (it is very important that you check your LEDs are common ANODE, or else, the cube won't work!!)
  • a LOT of Solder!

for more advanced functions;
  • 3x 8k2 resistors for optional, low power mode.
  • 3x 3pin male headers for jumper selection of the power mode
  • 3x jumpers for selecting the power usage/brightness setting
  • 2 x 64KB EEPROMs for storing custom animations
  • 1x DIP switch for selecting different modes (random, serial, music responsive, random2, custom animations, etc.)
  • 2x MSGEQ7 chips for audio analyzing and music response.
  • Black paint

Tools;
  • An Arduino to use as a USB to Serial converter for programming
  • An USBTinyISP if your Atmega chip is not pre-Bootloaded
  • A Multimeter for troubleshooting and checking connections
  • Some way of cutting PCBs, I used a Circular Saw, but you can use whatever you have in hand.
  • Diagonal cutters
  • A Sharpie or any kind of marker
  • A Drill/Drillpress
  • A Cutter or Xacto knife
 
Remove these adsRemove these ads by Signing Up
stewe95112 days ago

Would this work with an Arduino MEGA 2560? Please relpy

mbrotcke28 days ago
mbrotcke made it!2 months ago

Here is an updated schematic. with the MSEGQ7 chip added in, and a rest circut for those with out an auto rest programer.

I'm not sure how to code the MSEGQ7 in to this cube, so any help would be great!

4x4x4-light-cube (1).pngIMAG0468.jpg
stucks mbrotcke2 months ago

I plan on building this myself. I'll probably start writing the code while I'm waiting for the parts. I have used the MSEGQ7 chip in many projects so I'll be happy to share what I come up with. One question: where did you source the uninsulated wire that supports the structure? Also, what LEDs did you use?

mbrotcke stucks1 month ago

Also, GreatscottLabs built one very similar. http://bit.ly/1vUOasm . His code also works with basic changes. BUT i like This code better.

mbrotcke stucks1 month ago

That would be great! I used 18 gauge Bus wire. but it was a PAIN to fit through bread board, had to dremmel an angle on each wire. I will use 20 or 22 gauge next time i built it, BUT the 18 Gauge makes it super strong.

I used CLEAR common ANODE LED's, from ebay... http://bit.ly/1vUMX4h

Hope to see your code soon. I had to make a few changes to his code to make it work with the way its wired up, all of which i found in these comments. I can send you what i have if needed.

mbrotcke2 months ago

Have my Cube built and Atmega programed. It turns on with the Main code and starts to run, But the LED's are Dim and each color flickers as it's fading in and out. as if it's to low on power. After a minute the top layer goes on solid and the rest turns off (like the chip locked up)

I am using a 5v 2A power suply, have tried two of them.

Any suggestions? I have looked for shorts, and test connections

Thank you...

mbrotcke mbrotcke2 months ago

So I have determined the flickering is part of the PWM used for fading by the 5940's. i wonder if there is a way to turn that up so it's not so noticeable.

Also the cube seams to work fine via USB power from my PC.. so it's just my larger power supplies that cause issue!

http://youtu.be/zscuqmPN3rM

mbrotcke2 months ago

I made a full schematic of the "Basic cube" So you don't have to go back and forth. I

4x4x4-light-cube.png

Thanx dude :) Thats what I´ve been waiting for a long time :D

sinaarian5 months ago

Can someone send me the file that is working on a cube. my cube is built but i cant find a code that works with out any errors? The one in this instructable is having a lot of errors and anything with the TLC5940 name is a error or "not decleared in this scope" . CAN SOMEONE PLEASE SEND ME A WORKING CODE. I NEED HELP

ethoxx sinaarian2 months ago

If you didnt solve it by yourself: The code is working, you just dont have the tlc5940.h in your Arduino library folder. Download it here: https://code.google.com/p/tlc5940arduino/

rover87723 months ago

Hi , I build your cube on a breadboard (the electronics, not the cube ...). If you connect the red leads to the first tlc, the green to the second and the blue to the third, with ,starting from left to right on the first row of led's, right to left on the second row, left to right on the third row and finally right to left on the last row, then you can map your leds from 0 to 47...hope this make sense...

mzak26 months ago

How are the mosfets suposed to be wired? I have the layer pin to the leftmost pin center pin goes to actual layer and third pin with 2k resistor to 5v

bill3780 mzak26 months ago

The leftmost pin comes from the ATMEGA328P chip, The center pin goes to the layer and the left pin you have described correctly.

bill3780 bill37805 months ago

correction

and the rightmost (3rd) pin you have described correctly.

mzak2 mzak26 months ago

I can't seem to be able to have different layers on at the same time.

Any advice?

bill3780 mzak26 months ago

Which program are you running? RGB_4x4x4_LED_Cube_main_1 is the program that will light up all layers. If you are running RGB_4x4x4_LED_Cube_map_1 then only 1 layer will light up. This is the program that you use to find out the sequence of the LED lights, so that you can reprogram RGB_4x4x4_LED_Cube_main_1.

AlejandraG6 months ago

Hello! I need some help, i've been looking for the zip file which contains the code but I can't find it anywhere, could anyone email me the code? i'll be very thankful.

jimmy6197 months ago
Hi there! :) Could someone please explain me the code.Also I'll be very thankful, if someone could email the whole code . It's very important because i'm building a 5x5x5 rgb led cube for my project in college. Please reply as soon as possible.
Thanks in advance ! :)

cammace jimmy6197 months ago

hey jimmy, I've spent sometime working on this cube and can tell you a bit about the code. First off, the code is actually posted in a zip file within the instructions but you will also need to download the TLC5940 header which can be found here: https://code.google.com/p/tlc5940arduino/ . you'll have to place the file within your libraries folder in arduino. Once you have this all you have to do is redefine some of the pins on both the arduino and the TLC's. It's a similiar process described within the instructions. Honestly, once you get a good grasp of what your doing you can rewrite some of the code and take out a lot of it to make things simpler. Another important thing to do within the TLC header is to change the number of TLC's in your circuit. this function can be found within a file called something like "config.tlc". I hope this helps you out a bit, feel free to contact me if I didn't answer something.

sinaarian cammace6 months ago

i went to the link but i don't know what to go to get the code. can you help me , i just got done with the cude.

Hi cammace, I am building the led cube but I can't find the zip file within the instructions, could you be able to email me the code? I would be very thankful.

Hello cammace, i've been looking for the zip file within the instructions but I can't find the code, could you be able to email me the zip? I would be very thankful :)

sinaarian6 months ago

Every time I try to upload the code I get all of these random undefined for things like TLC and PD4. Can someone help me to get the code figured out. Thanks in advance

You need to download the TLC5940 header file. That should resolve your TLC errors. See the comments below by cammace and where the file is. What kind of errors are you getting from PD4?

Anything with a TLC in front of it is counted as not declared

mzak26 months ago

So i have everything working now based off of the arduino alone. Way less parts! So i have the layers mapped out, i have all of the pins mapped out, but when i program the cube to only turn on certain lights from the top layer, i get "ghosting" and all the lights below the ones i wish to turn on turn on as well. so if i only want the top left light closest to me to be on, i get the entire column lit up. Anyone else have any insight?

image201404170001.jpg
bill37806 months ago

Hello to those out there that built this cube and only got some of the layers to light,

My build of the 4x4x4 cube only got 3 layers to light up. After checking all the connections, i then started to look at the code. I started playing around with the pin number that are set for the PinMode command. Here is the code that i was looking at. It is in the RGB_4x4x4_LED_Cube_main_1 at the beginning:

#define LayerOne 16

#define LayerTwo 4

#define LayerThree 2

#define LayerFour 15

So, i changed the number for LayerFour from 15 to 17, and presto magic, all 4 layers are lighting up.

mzak26 months ago
Hey there,
I'm trying to get this together but was wondering a couple of things. First how is it powered? Second, can this be made from the arduino directly sans the atmega? Third, how do you connect the 1000uf capacitors? From what vcc?
GranpaO446 months ago

In your instructions, you say to use Common Anode RGB LED's The long lead on them are the "+" lead. On page 6 of the instructions, you state that the long lead of the RGB is the "-" negative lead. That would make the LED Common Cathode.

Was that a wrong statement on page 6?

bill37807 months ago

Howdy, great job on the article to build the 4X4X4 LED cube. I just finished building the cube and started to test it out. Got the top three layers to light up and trying to figure out about the bottom layer (#4). The code in RGB_4x4x4_LED_Cube_Main_1 object has these lines of code that i'm not sure what it means:

#define LayerOne 16

#define LayerTwo 4

#define LayerThree 2

#define LayerFour 15

Just want to understand more about the code. Are the numbers referring to pins? on which chip?

Thanks

cammace bill37807 months ago

I'm having the exact same problem as you. What MOSFETs did you use?

bill3780 cammace6 months ago

I used IRF9540N MOSFETs.

mbrotcke7 months ago

Which MOSFET p-channel transisters do we need to use for this?

lgruen made it!8 months ago

Awesome tutorial! Had lots of fun building this.

Small error here: "3. Start bending the leads (the Rightmost lead goes to the bottom left at about 45 degrees) (pic 3)." should be "goes to the bottom right".

I've placed my MOSFETs very close to each other, similar as in your photo. However, after some debugging I found out that they'll actually short if their heat sinks touch (which in my case only happened when putting the PCB layers together ;) ). It would be nice to mention to be careful about this.

Some guidance about the power supply would be nice. I guess in practice a 5V / 2A wall wart is good? Batteries deplete amazingly quickly with this :).

led-cube.jpgIMG_6257.jpg
msadeghlou9 months ago

hi tanks for your guidance, I have a problem with your design, according to your circuit when we set the red pin in a column we set it in all of it and we can't have different color in a column.

sorry for my bad english

tomriddl310 months ago
how hard would it be to adapt this to use common cathode LED's?? any help would be appreciated :-P
Steve25 tomriddl39 months ago
Wow i bought cathode leds too :(
tomriddl3 Steve259 months ago
any luck?? got my cube all soldered and ready to wire the driver circuit xD..
Steve25 tomriddl39 months ago
Well i found this rgb led cube. It uses cathode leds but there is a lot of ghosting going on. Check this link for the guide: http://g33k.blogspot.nl/2013/03/charlieplexed-4x4x4-rgb-led-cube.html
tomriddl3 Steve259 months ago
thank you sir! .. but i had already solder my led's as per this guide :-( .. smh!!
... will have to keep digging :-P
quixeh9 months ago
Thanks for the guide - its a brilliant project and kept me entertained for a few days of lead-inhaling fun! Really like some of the techniques for chip placement and painting the boards black, looks good.

I should probably mention a couple of issues I found: You need to download the TLC library from google code in order for your sketches to compile (and place them in your arduino library folder), and you need to change the config file in the library to use three TLCs rather than just one (read the basic use example) before things will work correctly. Otherwise, mine looked like one or two of the TLCs were stuck on full brightness and didn't work in the mapping stage.

Once again, brilliant write up and brilliant project! :D
Steve2510 months ago
Why didn't you use resistors to protect you're leds and TLC's?
Emiliano Valencia (author)  Steve2510 months ago
They are not needed, the TLCs have embedded current regulators for each LED, you just use 1 resistor to set the current.
Thanks
BubbaFish777710 months ago
I built it, and I am having the worse time trying to figure out the code settings and the LED mapping. Any and all help would be most helpful.
It would be easier if Emiliano would add his mapping of the leds. Hopefully he will do this!
Steve2510 months ago
Can you show us wich pin of the TLC's you connected to what column. And put number 1 to 16 at you're columns to make it way easier. If you add this is can start building it! Really hoping you will include this!

Thanks
can some1 give me the schematic,. so i can start building this!!
please
thanks,..
sir small doubt regarding the power supply!
im doe with ther cube and im using our clg LAB RPS to power my cube.now im planing to use pc smps.ca i dircetly conect the smps 5v rail same as rps? smps has very high current ratings,does it make any damaga to my cube?
thankyou
hey1011 year ago
I am working on building this cube. Could you clarify where the capacitors go between Vcc and Gnd or does it matter where they are placed?

Also I think i found a mistake in your parts list. Near the bottom of the instructions you say:
"the 2 1000uF caps from Vcc to Gnd;
the 2 100nF caps from Vcc to Gnd"
and in the parts list you have:
"1x 1000uf 10v capacitor"

Shouldn't that be two? Also the other cap is not listed.
hi, i just built http://www.freetronics.com/products/cube4-4x4x4-rgb-led-cube#.Udkz7VMZJkg
a 4x4x4 adrunio rgb cube .. how can i program it to display like yours?
fffrune1 year ago
Could you post an alternate schematic for using just the bare chip? That would be easier than trying to translate from the Arduino mapping to the chip mapping.
parry4531 year ago
In fact, after trying it again today, I have found that when I reset the microcontroller, my cube led's do light up for a split second then off for a second and then on again for a split second. It carries on repeating thing. The only thing I have done different is to wire up the MOSFET to Arduino using thin wire. Would this cause it a problem? Is the Thin wire struggling with the current? Also the LED's are very dim... I need to turn the light off to see them light. Any Ideas??
Thin wire from MOSFET to arduino wouldn't cause a problem as the arduino only provides a small current to basically flip a switch in the MOSFET. The higher current that powers the LEDs flows through the other contacts.
hey1011 year ago
I looked around but could never find an LED driver that would work. So I just ordered the common anode LEDs. Where did you get the PCB from? Also what do you recommend for powering the cube?
parry4531 year ago
Hi Emihackr97,

I have built the cube, and the circuit. And when I go to upload the program onto the chip it says it does it with no problems. But nothing happens after that. No patterns, no lights, no anything.
Did this happen with you? i'm using the power from the Arduino Uno board/fed by PC.

Any suggestions would be great!
hey1011 year ago
I already have common cathode RGB LED's. What would it take to modify the circuit to use those instead of a common anode? I can modify the code myself but I am not sure on the circuit side of things. Thanks.
Emiliano Valencia (author)  hey1011 year ago
Hi, unfortunately, the TLC5940's are an open collector sink only constant current drivers, which means they can only connect LEDs to Gnd, not to Vcc, therefore you need the specified type of LEDs if you want to use those chips, you could search for some different chips, but I can't guarantee you it'll work.
I used 4.7k for the TLC's. Weird, i guess ill recheck all the wiring and make sure nothing is shorted or anything. I used 10k for the pull-ups on the FETS but that shouldnt make any difference. I'll use a different supply and see if it works and ill make sure to take a video in case it does the same thing again.
yeah.. so i blew another power supply. This one was rated to supply up to 2 amps. I really dont understand what could be going wrong. The lights turned on but didnt change colors or anything. I might just have to toss this project as i cant afford to keep wasting money on power supplys.
BIGDOG19711 year ago
This is a marvelous work.
Very nice... Super!
Congratulations.
What current am trying to get for this? And that definitely makes sense then because if it couldn't handle the current the cube was drawing then it would burn it out for sure. And I'm sorry, i was going to take a video but it burnt out before I had the chance haha.
Well, depending on the resistors you used for the TLC5940's, the cube could take up to 1 amp of current
Rrrghhh. Thanks for the quick reply on the last question. So i got it programmed but then when i plugged it in.. It flashed rapidly and did not fade as its supposed to then popped my wall wart. Any ideas?
Ok, my first idea on this one would be that probably the wall wart wasn't able to give enough current, therefore the voltage dropped, causing the Arduino chip to work improperly (flash?) and, at the same time, the wall wart overheated and maybe burnt.

I would recommend checking the specks of that wall wart to see if it can output enough current, and to try to power the cube with something like a computer PSU to determine if the problem lies in the cube itself or in the wall wart.

P.S. I can only imagine the problem from what you tell me so try to be as descriptive as possible so I can get a better idea of the problem.

Cheers, please keep in contact.
Im getting an error and cant figure out why so i cant upload the program to arduino.
Here is a screenshot http://camsconstructs.wordpress.com/2013/02/11/error/
parry4532 years ago
Hi emihackr97,

Love the cube! a quick question :

Did you manage to connect the MSGEQ7 for music response?

Thank you

Parry453
Emiliano Valencia (author)  parry4532 years ago
Not yet, As i'm still a student and school takes most of my day, I haven't had time to tinker around with that, but I already have the chips and i'll do it as soon as I find time.

cheers,
emihackr97
vvien2 years ago
Thanks for answering, I managed to make the LED cube to light up. But the problem now is that after I uploaded the program, I didn't get the flowing hue lights like the one in your video. In one of the columns, the color changes, but the others stays in the same color the whole time. And after about 1 minute, only the first or second layer would light up. Do you have any idea what the problem might be? I used a 5 V USB as the power supply. Thanks :)
Emiliano Valencia (author)  vvien2 years ago
Hmm, perhaps it might be some mismapped wiring, maybe if you could get a video of it I can more easily try and diagnose the problem.
It's great that you´re building it,i'm acually currently adding the MSGEQ7's to mine so it can respond to music, that update will (Hopefully, if they work as intended) be up soon.
Here's the video:
http://www.youtube.com/watch?v=Dplms7SouR8&feature=plcp

As you can see there only a few are changing colors, but the other stayed in one color and some are blinking.

Wow, I would definitely love to see your cube when it's done with the upgrade. :)
Emiliano Valencia (author)  vvien2 years ago
Hi, sorry for the late response, but I was out of town, I can see that your cube is really well built and that, at the beginning, all the LEDs light up, it's after a while that it "Freezes". this is not a problem of your cube, it's actually a bug in that code which I haven't been able to find, it happens to my cube also, but only sometimes, how often does it happen in yours??
It happens quite randomly, sometimes it immediately freezes, and sometimes it can lit up for two minutes and then freezes. Even so, I did not get the LED cube to be like the one in your video (the hue changing like a wave). did you use a different code for that video?
Emiliano Valencia (author)  vvien2 years ago
BTW, I'm just smoothing up the next version of the code, which will treat the cube as a 4 dimensional array and should be faster and super easy to modify, i'll tell you as soon as I finish it! ;)
gcbalster2 years ago
Hi emihackr97

got a few question about the schematic
-are there alternative for the BUZ171 if yes which one ? (Q1 -Q4)
-why are there resistors by the buz171 and whitch one? an d not on the schematic.
-which are the value of R1,R2,R3

thank you
Emiliano Valencia (author)  gcbalster2 years ago
Hi, in fact, any P-channel MOSFET will work, I just wrote that in because that's what I used, the resistors aren't on the schematic because I frankly forgot to put them in, they are just to default the mosfets to the OFF state, they go between the gate and +5v and they can be anything from 1k to 100k.
R1, R2 and R3 can be anything 4k and 10k (they must all be the same) they are the current setting resistor s for the LEDs, the higher the resistance the lower the current, so the brightness will get reduced, however, the power consumption is reduced aswell.
Hi emihack97
ihave one more question how dit you connect the dipswitch?
Emiliano Valencia (author)  gcbalster2 years ago
Hope I solved all your questions and make sure to post pics if you do build the cube!
Goodmornig emihackr97

Thank you for your awnsers
For now it solved a few questions, when i build a bueatiful cube as yours i think i wil have more.
and when i,m finishd i wil send a picture of the cube.

thanks
Cello622 years ago
Hello. Congratulations, you did a nice project.
Emiliano Valencia (author)  Cello622 years ago
thanks!
paler312 years ago
Hi I am going to have a go at building this, but I have a question about the resistors for selecting maximum current output. I am sure my LEDs have a 20mA maximun current but using a 4K7 ohm resistor according to the data sheet and my calculation only gives a max current of about 8mA. Is this still ok? or have I missed something?

John
Emiliano Valencia (author)  paler312 years ago
Yes, it's still ok, the 20 mA are the maximum current you are supposed to give them, anything below is fine, as long as it's bright enough.
ok thanks for that. I have a sneaking suspition that the led's i have saturate well before 20mA anyway.
hi, depending on your programmer, it should have all pins labeled, match them with the pins on the arduino pinout diagram.
you need to connect RESET, Ground, Vcc, RX and TX, you may need to reverse the RX and TX lines depending on the programmer you use.
vvien2 years ago
Hello. Thank you for replying the last time. I have another question: how to program using the pins? which one goes to which? thx. :)
I don't quite see where the 2 1000uF and 2 100nF capacitors are supposed to go. Are they all supposed to be in parallel attached to any ground and 5V?
awong192 years ago
Hi, your cube is beauiful!. If i were to build one like this and connect to the arduino nano instead of the bare chip, how would the schematic differ? Thank you.
matt_v2 years ago
hi there i am very interested in building this cube and was wondering if you have managed to get it to work with the msgeq7 and if so could you post an upto date sch as im just making a shopping list of parts..... cheers
vvien2 years ago
I'm trying to make this as we speak, one question: what do you use as the power supply? batteries or usb? thx :)
Emiliano Valencia (author)  vvien2 years ago
The cube is designed to accept regulated 5 volts ONLY, if you want to power it with a higher voltage you should add an LDO regulator, i personally power my stuff with an ATX PSU for testing but USB should be able to supply enough current.
Is it possible to make a bigger cube using this instructable?
Emiliano Valencia (author)  RobertRobbie2 years ago
If you mean making it physically bigger, the yes, if you mean making it with more LEDs, then no, as this Cube is at the limit of pins from an arduino and almost at the limit of it's processing abilities.

for a bigger cube, I would use a Parallax Propeller microcontroller, as it has 8 INDIVIDUAL CORES which would be able to handle more tasks at the same time.
Cool, Thanks For your help... I think I will build this one first then maybe do some research into that later.
dfitz10002 years ago
Do you have a circuit diagram? I'm struggling to follow what needs to be connected to where. Thanks.
Emiliano Valencia (author)  dfitz10002 years ago
The schematic is up now, please post pics if you build it.
Emiliano Valencia (author)  dfitz10002 years ago
I'm working on it, it'll be up soon. ;)
I'll notify you when I have it, hopefully tomorrow
Thank you :)
That is insane! Awesome work!
dfitz10002 years ago
I don't follow the steps from here on, is it possible to just use an arduino uno instead of all the stuff that you do from this step on?
Emiliano Valencia (author)  dfitz10002 years ago
Yes, I use the bare chip to keep the cost down, but you can use the whole Arduino UNO or DUEMILANOVE.
moshe_S_m2 years ago
A really nice and clean work,
Nice to see :)