Instructables

How To Write Your Own 4x4x4 LED Cube Show For Arduino

There are Many Instructables out there teaching you how to build an LED cube, however only a few actually help you write the code to go with it but rather just give you some to use, thus stopping your creative potential! Also there are many different ways to program the cube, but this is one of the simpler ways I found so far. If you don't know where to start, start here!

This instructable will be an "addition" onto my previous one on how to make the LED cube itself. It can be found HERE.
For those of you that built my cube, consider this the last few steps.

This instructable assumes you either know how a LED cube works or have built one yourself.

Also I assume that you have built a 4x4x4 cube (because that is what I have to take pictures of). However, this will work with any cube if wired properly.

Note that the code and cube run on Arduino.

Also, I lay no clam to the code found in this instructable, I have simply altered an existing code that has been floating around the internet. My hope her is to further explain this code in a way that people which have no prior knowledge of coding can form and write their own shows. If you are or know who originally wrote this code feel free to contact me!

Things Needed:

  • An LED Cube
  • An arduino mega or uno, according to cube size
  • Arduino IDE
  • Computer
  • A fair amount of patience and time


Video of new pattern I wrote(Show 2):

 
Remove these adsRemove these ads by Signing Up
Michael_Bell4 months ago

Did you ever figure out who wrote the original code? I made a web application for editing these animations, and I would like to know who to credit :)

Micheal_Bell - Yes this interested me too. I asked exactly the same question on the Arduino forum here http://forum.arduino.cc/index.php?topic=193436.0 There are plenty of people all over the net laying claim to this code and sorry to be a "doubting Thomas" but looking at the OP's other code example like _4x4_LED_Cube_Sequence_1 which is a low level beginner coding, I sincerely doubt the the OP wrote the more complex code examples that he is claiming are his. Sad really that people feel the need to plagiarise the work of another to make themselves feel important. Also I would be really interested in having a look at your web app for this code if you are willing to share it. I promise that I will not claim it as my own work :-)

jtmanders (author)  pedro1472 days ago

I never did lay clame to the code. I stated I am not the one who originally wrote it. The basis of this instructable was to teach people how to use this code, because it is not clearly stated anywhere on the internet. Therefore for someone that doesn't know what they are doing this provides a very simple solution. When I say I wrote them, I clame I wrote the program design and the light patterns found in the code. However, I did not write the foundation of the code. But as you said, no one knows where it came from or who wrote it.

Thanks,

Maybe it would be prudent to edit your Instructable and
reword the statement "Video of code I wrote(Show 2):" situated
above video titled "4x4x4 LED Cube (NEW CODE) This would differentiate
between you writing a code "pattern" as opposed to writing the actual
code itself, as there is a rather large difference I think you will agree. By
the same token I appreciate that your motive was to show how to use the code to
write patterns by showing how the B000 "code blocks" relate to the
LED positions within the actual cube. I agree this is a helpful piece of
information and I applaud you working this out and sharing your discoveries. In
closing I would just like to say that overall you did a thorough job of
explaining the cubes construction and operation – Well done.

jtmanders (author)  pedro147yesterday

Fair enough, I'll do it! I appreciate it!

varooj.pink1 month ago

tnx I love it

hwillard10 months ago

I bought the parts to build this on ebay as a kit. The seller was from over seas. This is my first time doing one. Sounds like I built the cube backwards.

I have wires going directly to the Arduino Duemilanove. I don't have transistors. I believe I had (4) 2N3904 NPNs hooked up originally. Looking at that, do I need to use PNP Transistors instead; since it is wired backwards. Or is there a change that can be made in the code.

I appreciate the time, I have been pulling my hair out. Great instructable by the way.

jtmanders (author)  hwillard10 months ago

I dont think in the long run the fact they are backwards will make much of a diffrence. Because the whole concept it to complete the circuit which is done either way.

Good, my code does not use any transistors.

Since it was a kit, did it come with any type of instructions? or its own code?

jtmanders (author)  jtmanders10 months ago

And thanks!

hwillard10 months ago

Ok, I built the cube, wired it all, started doing code. I can make a code for it to light top layer then 2nd, 3rd, 4th in order. I, however, cannot figure out what to write to do the columns, nor can I figure out how to write code to do each corner, also, is it possible to light one led at a time.

my layers are using anode (+) hooked to pins 13,1211,10, cathodes (-) are columns using pins 0-9 and 14-19. Arduino Duemilanove.

Here is first lines of code:

B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,35, //TOP
B0010,B0000,B0000,B0000,B0010,B0000,B0000,B0000,B0010,B0000,B0000,B0000,B0010,B0000,B0000,B0000,35, //SECOND
B0100,B0000,B0000,B0000,B0100,B0000,B0000,B0000,B0100,B0000,B0000,B0000,B0100,B0000,B0000,B0000,35, //THIRD
B1000,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B1000,B0000,B0000,B0000,35, //BOTTOM

Please help.

jtmanders (author)  hwillard10 months ago

Ok, from the info you have given, it sounds like a hardware problem to me. Because technically to light an entire layer the code would be

B1111,B1111,B1111,B11111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,

Which turns on all of level one.

The lines of code you have posted above, given the hardware is correct, would light single columns.

Think about it logically, every 1 stands for an on light, every 0 stands for an off on. Therefore to light up an entire layer, there must be at least 16 on, or 16 1's in the line of code.

What you have written above is the correct code to light up single columns. The fact they are lighting up entire layers says something is wrong with your cube wiring.

Things to try:

Make sure you are bypassing the transistors.

One thing that struck me was that "my layers are using anode (+) hooked to pins 13,1211,10, cathodes (-) are columns using pins 0-9 and 14-19." Because that sounds backwards... the layers should share a common ground(cathode) and the columns should share common anodes. However, this might not be influencing it as theoretically this might not matter...I honestly don't remember.

Make sure you set the code to go with your cube. Refer to step One.

Hope this helps!!!

Tyler14061 year ago
Hey, I'm planning to re build my one of these but with RGB common anode LEDs
I really want to have a working code before I build it as they're more expensive and time consuming.
What I want (plan) to do is as they're common anodes, the 16 columns will remain as normal, but I will make 12 layers instead of 4,
I.E TopRed, TopGreen, and TopBlue,
2ndRed, 2ndGreen, and 2ndBlue,
3rdRed, 3rdGreen, and 3rdBlue,
BottomRed, BottomGreen, and BottomBlue,
With this, I would be able to not only control a single LED, but also decide if it's red, green or blue or all 3.
Problem is I'm not very experienced in Arduino and don't know how to do this.
If you or anybody you know would be able to help me or point in the right direction, that would be fantastic, I'd *LIKE* to keep the code in the B000, B000, B000.. etc format but if it's impossible so be it. I'd also not rather use any other IC's besides the arduino. Basically I want to know how to write a code for a 4x12 LED cube.. If you could help that would be appreciated.
jtmanders (author)  Tyler14061 year ago
Honestly, I have never researched about RGB cube.. I have no idea how to begin with a code like that. I'm sure there's one out there though, so look around. Sorry I'm no help. Good luck
gazza12331 year ago
this has saved me so much time as i could not figuer it out im ok with building stuff just not that good at the program stuff would this work with an 8x8x8 thank you
jtmanders (author)  gazza12331 year ago
Technically it would work with an 8x8x8, however there would not be enough I/O pins on any arduino. So if you make an 8x8x8 I suggest you do what I did and follow chrs instructable. I made an 8x8x8 following his, so if you have any questions ask away.
jtmanders (author)  jtmanders1 year ago
Oh and the code would probably work I don't really know, just very time consuming and relies on the hardware you make
Tyler14061 year ago
This was great ! I followed your first instructable to make the actual cube but as you said, it's only really doing codes that others have wrote. I sort of had an idea how the code works but never really looked into it, thankyou for clarifying this and making one of the easiest cubes without tons of work i.e shift regulators and the works. By far the best 2 instructables on an LED cube I've found. Hopefully will see an 8x8x8 one soon ;)
jtmanders (author)  Tyler14061 year ago
Hey thank you! 
Well ten you will be happy as I am making one right now! I am following chrs instructable, but I hope to make one for complete beginners guide and explain everything further In depth. Hopefully with some better schematics too.
image.jpg
If you want any help with that, let me know. I am the one that wrote the 8X8X8 cube revisited instructable.
Awesome ! I can't wait until it's done so I can make one for myself ! That's good seeing as all the ones on here aren't very detailed especially in the schematics. Looking forward to seeing it !
'earl1 year ago
Hey, voted for this. I have a 4x4x4c cube and this was the code type I found to make it work. Very time consuming but I have quite a few animations for mine and this inspired me to re program it and add new animations. Running out of ideas however.
Tyler14061 year ago
Awesome ! I can't wait until it's done so I can make one for myself ! That's good seeing as all the ones on here aren't very detailed especially in the schematics. Looking forward to seeing it !
maewert1 year ago
Nice instructable. 

I am sure there are many other methods of accomplishing the same thing. 
In my 5x5x5 cube I put all of the LED cycling code into an interrupt routine which is called based on a timer.  This way I can be sure all of the LEDs will appear the same brightness since the 'on' LEDs will have the exact same duty cycle without using any busy-loops (i.e. delay(x) routines).

I also abstracted the code so the software has simple set and check routines ( like: setOn(x,y,z), setOff(x,y,z), isOn(x,y,z), isOff(x,y,z)  where the x, y, and z are which LED in the three dimensions you wish to access). 

Then I can show a ball bouncing in the cube, or filling up with rain, or a snake roaming around inside it, etc. always changing directions based on the pseudo-random number calculator.  I can have letters scrolling through the cube received from the serial port (which requires more LEDs than your 4x4x4).  It allows a more traditional programming than sets of pre-defined canned images.

As I said before, lots of ways to do it, each has its advantages and disadvantages.

Best Wishes.
jtmanders (author)  maewert1 year ago
Thanks for the comment! That a great idea! I knew there were many ways to go about this, this is just the first things I figured out. I'm sure there is someone out there like me that had no idea where to start, so this is a good starting point anyway.
Thanks,