Step 9: Compile and program

You now have a led cube. To make use of it, it needs some software.
I have made a driver for rendering a 3d data space on the cube, and functions to display some cool visual effects on the cube.

You can use my code, write your own or build on my code and make more effects.
If you make your own effects, please send me the code. I'm eager to see what you guys make!

To compile the program. Just open a command promt,
enter the directory with the source code
type "make" on the command line.

If you want to use an ATMega32 instead of the ATMega16, just change the mcu setting in the Makefile and recompile (type make). If you use the m32 and don't do this step, the cube won't boot properly (the red and green lights will keep blinking forever).

You should now have a file named main.hex in the source directory.
The next step will show you how to get that code into your cube.
Mrwolf811 year ago

i see people can't seem to read.... it's not hard. 'save as' re-name


to main.hex. upload to atmega16 chip and you are done!

ClA0075 years ago
i have a question  how do i use the zip file? the hex i can use it from windows to send it to avr but the zip i didn't know how to use..! can someone tell me if it s important o not?

the zip file contains the original naked coding files which you can edit if you want to, but if you dont know what you are doing... dont touch it.

if you uploaded the .hex file... you've completed the programming of the atmega chip and theres nothing more you need to do

How do you connect an avr to your pc for the code to load on it? And yes I do have linux

you need a gadget called a 'usbtiny' which is available on Ebay

Bartjeeh5 years ago
so this is what i do. and i really don't understand what i do wrong.

Bartjeeh@linux-b5pm: cd /home/Bartjeeh/Desktop/4x4x4_ledcube
Bartjeeh@linux-b5pm:~/Desktop/4x4x4_ledcube> make
If 'make' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf make

in that folder are the following files

if anyone could help me please!!!

change this file :


to main.hex

then type

avrdude -c usbtiny -p m16 -U flash:w:main.hex

mateuszrjzr3 years ago
I know, that last post was in 2008, but can you explain me why when i'm klicking "4x4x4_ledcube.hex" suddenly i am downloading something like : F6JRI6AFJ1I6CP0.tmp???? please so much help me...

before you click the link, right click on it and "save as", then change the filename to main.hex...

andrejmdias4 years ago
someone has the full pdf of this circuit to send
send: andrejmdias@gmail.com

if you can log in to comment you can login and download the whole pdf!

top left button with the pdf icon and the word "download"

karyochi4 years ago
i'm having some problems, when i use the make command, it responds with:"makefile: ***missing seperator", could someone plz help?, i want to use an ATmega8 or ATmega32, maybe somoene just could send me the HEX code, Karyochi@gmail.com.

dude, to change to the atmega32 you will need some sort of avr program writter like the one you can download from atmel (atmel studio).

open the makefile in atmel studio and then change this line...

mcu = atmega16


mcu = atmega32

and then compile and upload!

brujita0383 years ago
I opened the file "main.c" in the folder 4x4x4_ledcube in AVR Studio 5 but does not appear the option to compile .. Someone could help me with that please, because I have little experience in this program.
hoodkicks3 years ago
MCUCSR |=(1<MCUCSR |=(1<
If using the Main.c file Make sure to add the following code before your while(1) loop otherwise port c2, c3, c4, and c5 wont light up
Lionverse4 years ago
Awesome instructable! I have been looking to build a led cube and yours is the best I have come arcoss - very well put together with thorough instructions. I saw you had ported your 8x8x8 to run off arduino have you thought of doing an instructable on this cube with arduino for newbies like me that are not yey ready to loose the arduino safety net. I'm sure I am not the only one who would appreciate it!
npatankar4 years ago
hello frnds....i m very new to microcontroller programming....cn sm1 tell me how to program atmega16..which compiler to use...the rs232 connection shown in the circuit.....using tht programming of microcontroller hs to b done?
plz mail me step by step procedure to make it....on my mail id nikhil.patankar390@gmail.com

thanku..............its a awesum project..........i want to make it
d67uttam4 years ago
can you please tell me what compiler you used, AVRGCC will work ? please reply . it is an amazing job, I want to build this.
im new at this and i would really like to try this. i dont know much about programming, but if someone could tell me how its connected to compute. and what program to use to flash it would be helpfully. if you could email me thanks. jessebrobison@gmail.com
googl14 years ago
i created a fork of your code at git@codaset.com:googl1/led-cube.git
i did some improvements, bugfixing and started implementing some new effects.
domdomgin4 years ago
where do i have to put the hex file in which directory..i have usbtiny..it cannot locate the hex file to upload the firmware
yasoo7164 years ago
dude u are ultimate .....and hats off for your patients for explaining this............
trungnvfet5 years ago
If use PIC16f877a.How do me do?and need?can you help me.thank U. comment to me.i from VietNammess.
vo van! tu nghi di!
thank about this project.
how do you exchange from *.c    to   *. hex. i don't known software that.
can you help me.
thank! very much.
grajasekar5 years ago
In your LED cube 4x4x4 instructable, you've included 2 files for download. A zip file with all the directory containing c programs and a makefile. Another hex file is also available for download. So is this hex file that you've included a precompiled version of the one that we need to burn to the Atmega16 or do we need to compile/make the hex file from the c files you've given?? Please help. Anyone. Also, in the absence of the programmer being connected to the setup, where would the power to the cube come from?? Awesome instructable btw. Thanks in advance, Gaurav
PAKIS-RULEZ5 years ago
i am using serial to usb convector i tried using the "make" command as u said its not working please help thanks in advance! " C:\Documents and Settings\**************\Desktop\4x4x4_ledcube>make 'make' is not recognized as an internal or external command, operable program or batch file. "
G.hyme6 years ago
where is the bootloader for the atmega?
Abadon1256 years ago
Hi, I am very new to this type of thing. How is the cube connected to the computer? can someone post buy links for the Microcontroller and the Max232 rs-232 as well as how it is connected? Thanks so much! Really excited to start building!!
refuser6 years ago
Amazing instructable man! I really like this one and I have to build it once I finish with my led-pov. Thanks for this one. /Einar
poogemister6 years ago
Nice code! I really like the way you did it! Just a heads up, in your definition of ioinit, you made a small typo in one of your comments explaining the Data Direction Registers. // Data Direction Registers // Bit set to 1 means it works as an output // Bit set to 1 means it is an input If I'm not mistaken, to configure a port for input requires the bit to be set to 0. Just a heads up. I really like how clean your code is! Nice work! -- Alex DeLand
Fire_Leon6 years ago
Man i did this, with a microchip one, and i got it kind of working, here is the thing, if i got the anode with 5v and the transistor is not switching, the led should be off right? well some of mines arent goin off, the keep on, not as bright as if they were on but looks pretty bad, what could be the problem? ive checked a lot, i also cut the ground wires and unwired the transistors and those leds keep on without ground =/
jsyah6 years ago
Are you working on the "getting started with AVR" now?
arepark7 years ago
I am very interested in your project as a first micro controller project, so I would love to see an instructable on AVR basics. My arduino diecimila is on its way so I am looking for a project.
harsim897 years ago
Nice work man, But could you start a project for programing of AVR
van.dango7 years ago
Nice nice nice! Saw this one on some mediaartfestivals and love it. Ever thought to make one myself. And yes, when u like give some more instruction about how to programm the microcontroller. I have some experiance with the arduino but use it with puredata. So don´t know to much about stand-alone-programming. Anyway, thanx for this here