3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

LED Cube 8x8x8

Step 48Program the AVR with real code

Program the AVR with real code
So everything checked out in the test. It's time to program the ATmega with the real firmware!

For the most part, the process is the same as in the previous programming step. But in addition you have to program the EEPROM memory. The LED cube has a basic bitmap font stored in EEPROM, along with some other data.

Firmware is programmed using the same procedure as with the test code.

Firmware:
  • avrdude -c usbtiny -p m32 -B 1 -U flash:w:main.hex

EEPROM:
  • avrdude -c usbtiny -p m32 -B 1 -U eeprom:w:main.eep

-U eeprom:w:main.eep specifies that we are accessing EEPROM memory, in write mode. Avr-gcc puts all the EEPROM data in main.eep.

If you don't want to play around with the code, your LED cube is finished at this point. But we recommend that you spend some time on the software side of things as well. That's at least as much fun as the hardware!

If you download the binary files, you have to change the filenames in the commands to the name of the files you downloaded. If you compile from source the name is main.hex and main.eep.
« Previous StepDownload PDFView All StepsNext Step »
25 comments
May 1, 2012. 11:49 PMenSYS says:
Hi.I'm working on 9x9x9 since past a year.However owing to my wrong programming structure, can anyone tell me how do I exploit the existing 8x8x8 program for 9x9x9 ? Where all do I need to make changes ?
Nov 17, 2011. 9:56 AMbrucesallen says:
Just as with Test.hex, I am able to program main.hex and main.eep to the atmega32 but the result is just blinking (8 times a second) status leds. Depressing RS232 or other button causes one led on other off. No other IO port activity. Help.
Nov 18, 2011. 12:23 PMbrucesallen says:
video http://youtu.be/5fDqc3-_fko
Dec 27, 2011. 7:42 AMristdaro says:
I've just finished the project and powered up and apart from a few led's that require attention the cube works. The two leds on the board seem to flash alternately until I press btn 1 when the cube fires up into life and starts working through the various sequences in the main.hex progs etc

What I have noticed is that the sequences / patterns do not fully match the original video as shown by CHR. Have you noticed this also or have I missed something?

His video seems to have some really attractive complex waves which are missing on mine. Perhaps the code has been modified, just wanted your results to compare?

Thanks
Dec 27, 2011. 9:37 AMbrucesallen says:
Ah, yes.. The waves. I love the waves. If you read carefully you will see that the waves come from CHR's PC via the RS232 link. I hope to squeeze the sine functions into the AVR as others have done. I have not gotten waves to work yet either through PC/RS232 or AVR code. Now that the pesky family (all 12) have gone home I can get back to important things like this. And skiing.
Mar 9, 2012. 6:37 AMristdaro says:
Hey Bruce,

Have you had a look at triumphtotty's recent posts. He's managed to get the waves working on the ATMEGA32

I've uploaded a copy of his files for someone else on the site who was having problems getting them to run.

Worth a look they look great.

Mar 9, 2012. 8:36 AMbrucesallen says:
I'll have a look. I was just today going to get into the waves. I did manage to get the compiler working and have changed the text messages from "instructables" and "TG"
Mar 11, 2012. 1:53 AMchaserled says:
Hi Bruce how you change "TG" what file did you edit?
Mar 11, 2012. 12:26 PMbrucesallen says:
launch_effect.c
case 20
Mar 10, 2012. 12:20 PMbrucesallen says:
Whoopee! It works. I have waves! Thanx, ristdaro. About 20k of the 32k used.
I guess I'll have to use a real editor now. With CHR's software I was able to use Notepad on the C source files and Makefile (changed it to makefile.txt) but there don't appear to be line breaks in your that Notepad can recognize.
Bruce
Mar 19, 2012. 6:09 PMbrucesallen says:
and here is an updated video.
http://www.youtube.com/watch?v=6EifBi-9aas&context=C42f8adaADvjVQa1PpcFMOyS89wGmxL5aNEnXBz-jWfaPVXeLR1QI=

And on for my Arduino-controlled 5 meter long LED strip.
http://www.youtube.com/watch?v=vrOuTZaDviQ
Mar 11, 2012. 12:49 AMristdaro says:
Just install WINAVR

You can then easily edit the C source files using WINAVR's programmer's notepad and compile to your hearts content

Make sure you update effect.c (i've posted an update that uses all the layers (0-7)

Thanks again to Triumphtotty for his work on this
Dec 27, 2011. 11:25 AMristdaro says:
Now you mention it, Yes of course the rs232. Gives me something else to work on next - got to have the waves!!

First though I've just found a column of 8 leds that are not lighting at all, everything else around ok, nothing obvious so far like a loose connection - further investigation required. If i'm right it's unlikely to be a transistor but maybe on the 74HC574 side of things - strange -

otherwise it's great to have the cube up and running.

Thanks for your feedback and help
Dec 27, 2011. 2:27 PMbrucesallen says:
get yourself a great USB dual channel oscilloscope from Taiwan like I did. My PACO vacuum tube scope I built from kit in 1958 just wasn't cutting it.
Dec 27, 2011. 4:19 PMristdaro says:
Funny you should say that I've been looking at getting a scope, anyway I've found the problem (dry joint on a 100 ohm resistor)

The cube fully functional now, I'll post a couple of pics tomorrow

I've just got to congratulate CHR for publishing such a great project - its kept me happy for weeks!

Cheers

Dec 22, 2011. 1:55 AMristdaro says:
Hi,

Can you do me a favour and confirm that pin1 on (Roel's AVR board) SV3 goes to layer 0 or does it connect to layer 7 (cathode layer select) on the cube?

pin 1 layer 0
pin 2 layer 1
pin 3 layer 2
pin 4 layer 3
etc

or
pin 1 layer 7
pin 2 layer 6
pin 3 layer 5
etc


I'm trying not to get the cube upside down and I'd rather get it right first time without having to re-do my ribbon cable the other way round

Cheers
Dec 23, 2011. 6:23 AMbrucesallen says:
Pin 1 is the bottom (0) layer. I initially had my cube upside down but, since my cable receptacle had no polarizing pin I just turned the connector around.
Dec 26, 2011. 11:43 AMristdaro says:
Thanks for the info Bruce...saved me probably having to the same thing!
Nov 29, 2011. 7:59 AMristdaro says:
Good to see Roel Mulder's boards up and running!

I am hoping to follow in your footsteps. I have been sent the boards and have started the assembly.

Have you noticed the MAX232 T1IN and R1OUT are reversed on the ATMEGA32 RXD and TXD connection?

If you have any time saving words of wisdom to share it would be appreciated!

Nov 29, 2011. 9:02 AMbrucesallen says:
I have not tried the RS232 yet.
Important: the AVR programming cable must be plugged in backwards- at least with the ribbon cable I purchased. Use your ohmmeter to check.
There is no reset button. I added one.
There is no power-on led. I added one.
You can also see in the picture where I added a power connector for my 5v wall-wart cable.
As you can see, I used pre-terminated colored wires to run to the Ledcube base rather than the messy process of terminating 72 wires myself.
It is close to impossible to insert the 64 bottom leads of the ledcube into the base simultaneously. I did it by tilting the cube and doing one row at a time.
Dec 10, 2011. 12:34 PMristdaro says:
One step closer, I've managed to set the fuses and load main.hex and main.eep onto the ATMEGA with a cheap usbasp programmer off ebay. I'm glad I took your advice and added a reset button as it came in very handy after setting the fuses!

Thanks for the info especially the tip on the AVR programming cable.

I'm only on layer 3 of my LED cube so I've still got a lot to do, but it's nice to know the programming is done.
Nov 29, 2011. 10:25 AMristdaro says:
Thanks for the info I will remember to check the AVR programming cable!

I think Roel has perhaps redesigned the boards slightly as mine has a reset button, and a power on led

Out of interest what values did you use for

AVR Board
R2 - I'm planning - 10K from posts I've read
R3-R18 - i was planning 220 ohm
R20-R28 - 4K7 Ohm

Mux Board
64 x 100 ohm based on 3.0V forward voltage, 20ma LEDS
Nov 30, 2011. 1:11 PMr.mulder says:
Initially I left the reset and power LED out, but added them later as there was room to spare.
Nov 30, 2011. 3:26 PMristdaro says:
Can you confirm that Bruceallens's comment on the RESET button on the mux board doesn't work as reset as it's wired as an input?

I will have to take a closer look at the schematic, I don't doubt Bruceallen as his boards are working.
Nov 29, 2011. 12:30 PMbrucesallen says:
The button that is labeled RESET is not. It is wired as an input. Likewise the power on led is a software controlled output.

R2 10k
R3-18 220 ohm but my transistors are not driving the full load properly. Needs investigation. May need to be lower.
r20-28 4700
Mux board: 100 ohm.
Nov 29, 2011. 1:27 PMristdaro says:
Thanks for the feedback,

i dont; suppose you have an updated schematic of the mux board you could send me. A reset button sounds like a good idea.

So the reset on my board doesn't do much then I guess?
Nov 30, 2011. 1:13 PMbrucesallen says:
Whoops! I just found out why my transistors can't drive the required current. They are all in backwards! I followed Roel's photos of his partially assembled board. He has them in wrong. So check the proper insertion! So my ledcube is being driven directly by the microcomputer with no transistor assist!
Dec 17, 2011. 8:31 AMbrucesallen says:
So here is a picture of a new AVR board (from Roel) with the transistors oriented correctly. Works much better! Now when all leds are on it is as bright as one led.
Jan 5, 2012. 8:31 AMristdaro says:
Bruce,

Have you managed to get your hands on any new code for animations either on ATMEGA or PC via rs232?

I've got my rs232 working after installing Ubuntu, it's great to see the waves in action!
Jan 5, 2012. 5:44 PMbrucesallen says:
Been lazy. Too much family/holidays. I want to do some RGB LEDstrips!
Mar 10, 2012. 12:27 PMbrucesallen says:
And I DID! I found http://www.adafruit.com/products/306 led strip, bought 5 meters worth, hooked it to an Arduino and downloaded and compiler her code! DISCO!
Dec 18, 2011. 3:02 PMristdaro says:
Well Done! Glad that the transistor/resistor values are fine afterall

I've finished soldering my cube together - what a task

I've programmed the ATMEGA

Just need to connect the cathode layers / anodes to the cube.

I've still got plenty to do before I can test my setup
Nov 30, 2011. 3:44 PMristdaro says:
Wow,

I remember you saying that the R3-R18 value of 220 ohms may be too high as the transistors were not driving the full load, now I see why!!!!

I've just checked the board with my ohmeter and T1 base should go to R3, Emitter to GND and Collector to SV3 pin 8

I will make sure I double check when putting my pn2222a's in

Amazed that the LED cube was being driven at all.

Thanks for the heads up!
Nov 29, 2011. 2:36 PMbrucesallen says:
no new schematic. I just hung one off the side. Or you can forget it and just unplug power to reset. Processor has a reset circuit inside.
Dec 25, 2011. 3:09 AMthien2002 says:
Hi !

So the schematic isn't wrong with Reset button ? And can you post the working schematic ? I saw my friend make Led cube 8x8x8 with less device than here. So if can modify the schematic to use less device ?

THank you for any helps
Dec 26, 2011. 8:09 AMbrucesallen says:
The schematic as available in this Intructables has a correct reset button. Roel's initial board did not. As CHR mentioned, if you select a different transistor than the 2N2222, you will not need two transistors for each layer drive.
Dec 26, 2011. 7:15 PMthien2002 says:
Very thanks brucesallen.
Do you have the schematic and PCB of Croy9000 designed ? He designed the PCB very nice.
Dec 27, 2011. 9:20 AMbrucesallen says:
no, I do not have his schematic or boards. Good luck!
Nov 18, 2011. 12:20 PMbrucesallen says:
All works now. I just pressed the start button!
Nov 28, 2011. 10:12 AMr.mulder says:
Nice boards Bruce...

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
651
Followers
7
Author:chr
I like microcontrollers and LEDs :D