Picture of 3X3 LED Cube Programming tips (Arduino based)
How to make that cube do what you want it to!

I followed the instructable here and built a 3x3 LED cube run by an Arduino. I was delighted! But it could only do one routine. Again and again and again and again and again.... So I decided to try and program a different routine. I needed a change. Do you?

If you study the code in the cube's Arduino sketch you can see all the instructions right in front of you. To me, it looks like the Matrix, streaming by in all its digital confusability. I needed a graphic interface to help me code the routines. I FOUND ONE!!! But it wrote code that contained extra information that I did not want. How to rewrite all those instructions? Read on!

Be prepared, this is a twisted solution, combining an (apparently) anonymous website with a macro in my word processor, but in the end I have come up with a routine that is very powerful indeed!
Remove these adsRemove these ads by Signing Up

Step 1: Graphic pattern generator

I searched and searched for "LED Cube Programmers" on the web. I found some, but they were for PIC based cubes. I changed the title of my search to "LED Cube Pattern Generator" and BINGO! I finally found this one, and it allowed my simple mind to grasp the relationship between little flashing lights and gobs of 1's and 0's. I could punch little buttons on the screen and see a simulation of what I was doing! Just what I wanted. This generator allows one to use a cube of any size! Press the "new" button and you will be prompted to set up your cube.

'Insert' creates a new frame, just like a simple animation program. We are going to make a 'flip book,' in effect. Each page is programmed and then you hit the insert button to add another frame. Notice the speed parameter near the bottom of the window marked 'frames.' F and E mean 'Fill' and 'Erase.' Program a few frames and hit the 'Play' button. Your animation will be shown in the 'preview' window. Simple! When you are done and want to save your new light show, hit the 'File' button. You will see the buttons marked 'New',' to Code',' Load' and 'Save' appear. Press 'To Code,' and a window will open, asking you to choose in which order you wish to display your data. You can go back and change this later if you get it wrong. Just choose one for now.

You will then see a window with all your animation's coded bytes.
stringstretcher (author) 5 months ago


if you look at this site, designed by my friend to program these cubes, you will see the pin numbers in his setup code located in the code examples he provides. He uses these pins for his setup and it works great!

int g1=4;
int g2=3;
int g3=2 (pins 4,3,2 for the transistors, 5-13 for the anodes, as stated there)

A fantastic programming interface! Try it!!

rkshirsagar5 months ago

Could you tell which pins of Arduino are connected to transistors and which pins are connected to anode of led's, I mean the schematic of the cube.

stringstretcher (author) 10 months ago

If anyone tries this... you should have a look at this fantastic online programmer for 3x3x3 cubes:

Lots of great features, and no more need for this workaround!

Thanks Satvik for the coding and work there. You've done a great job!


I want to ask u about the I have done the led cube and I uploaded the code from the site but I have to change something in the code to make it work something like (a1),etc.CAn u help me please?

baitun1 year ago
It doesn't work for 4x4x4 cube.
arjan9011 year ago
i have a question about the code.
When i want to upload it to my arduino, i get an error on line:
int LEDPin[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10};

it says:
sketch_jan07a:34: error: expected ',' or ';' before 'int'
sketch_jan07a.ino: In function 'void setup()':
sketch_jan07a:45: error: 'LEDPin' was not declared in this scope
sketch_jan07a.ino: In function 'void loop()':
sketch_jan07a:95: error: 'LEDPin' was not declared in this scope

what can be the problem?
stringstretcher (author)  arjan9011 year ago
Your first error indicates a problem *before* inserting the changed lines. Check everything VERY carefully from the beginning and see if you can find a missing semicolon.
Eduort2 years ago
Hi, this is very interesting, but i have a question, is posible to program 2 or 3 routines and start them whit a button? thanks for afterhand
stringstretcher (author)  Eduort2 years ago
I never thought of that... why not? It is a matter of storing the routines as data, and then using a switch to select the data set, or the switch could select the starting point of the routine with case switch commands. There are others out there who are brazilians of times better at this than I am. We will have to seek the answer!!
Hanni432 years ago
Great able ,been looking for the led generator & everytime go to Download more junk seems to be getting downloaded than the program, where did you get it Wout all the other advertisers junk..Thanks for sharing project & time finding the way to go..D
stringstretcher (author) 2 years ago
I couldn't understand how to embed a video in any of the steps. Here is a link to one showing a short routine done using this method.