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 49Software: Introduction

Software: Introduction
The software is written in C and compiled with the open source compiler avr-gcc. This is the main reason we use Atmel AVR micro controllers. The PIC series from Microchip is also a nice choice, but most of the C compilers cost money, and the free versions have limitations on code size.

The AVR route is much more hassle free. Just apt-get install the avr-gcc compiler, and you're in business.

The software on the AVR consists of two main components, the cube interrupt routine and effect code for making fancy animations.

When we finally finished soldering, we thought this would be the easy part. But it turns out that making animations in monochrome at low resolutions is harder than it sounds.

If the display had a higher resolution and more colors, we could have used sin() and cos() functions and all that to make fancy eye candy. With two colors (on and off) and low resolution, we have to use a lot of if() and for() to make anything meaningful.

In the next few steps, we will take you on a tour of some of the animations we made and how they work. Our goal is to give you an understanding of how you can make animations, and inspire you to create your own! If you do, please post a video in the comments!
« Previous StepDownload PDFView All StepsNext Step »
24 comments
May 22, 2012. 7:14 AMsjowett says:
Hi There I've got the ATMega 324A PU 1106 and unfortunately am having some issues. Using avrdude it reports that the register name does not match (aparently the register is 0x1e9515) I've forced avrdude with the -F command and everything looks ok but the 2 status LED's do not flash. (what is the flash rate of the 2 leds?) Does anybody know what the difference between a 'P' and an 'A' version. After some searching I'm struggling to find any easy to read info on this subject. Anyway I guess I'll go out and try find an 'old' AT mega32 16PU as in the photo above! Any advice would be appreciated - great instructable!
May 2, 2012. 10:13 AMpawarotti says:
cannot download the filele cube_8x8x8-v0.1.2.tar.gz, can someone post the another linc?
please help!
Feb 29, 2012. 9:22 AMjtovar93 says:
Hi,

I have been loking at this tutorial and I am wondering if the microcontroller has to have the same numbers/ letters written on it...

In other words, would either of these microcontrollers work?

http://www.ebay.com/itm/1pcs-ATMEGA32A-PU-MCU-32K-FLASH-16MHZ-40-PDIP-ATMEGA32-/250891976699?pt=LH_DefaultDomain_0&hash=item3a6a53bffb

http://www.ebay.com/itm/1PCS-ATmega32A-PU-ATMEL-Brand-New-Original-/320854374464?pt=LH_DefaultDomain_0&hash=item4ab4693840

http://www.ebay.com/itm/1p-Original-ATMEL-ATMEGA32A-PU-ATMEGA32A-DIP-40-IC-NEW-CK19-/260901363057?pt=LH_DefaultDomain_0&hash=item3cbeeedd71

http://www.ebay.com/itm/New-1x-ATMEGA32A-PU-MCU-AVR-8-bit-32K-Flash-16MHz-Microcontroller-/230678624274?pt=LH_DefaultDomain_0&hash=item35b5847812
Feb 29, 2012. 1:40 PMjwestenberg says:
Since this is my first real project i can't tell you if u can use any of these. in this link http://www.sander-electronic.de/datasheet/AVR.pdf there is a datasheet with the differences between some atmega's. Maybe it will help!
Mar 16, 2012. 9:26 AMjtovar93 says:
Hi, sorry for the delay.

I appreciate your help, in the end, I decided to keep looking for an identical Atmega to avoid any problems.
Feb 21, 2012. 5:57 PMtarPancake says:
when i compile the custom code, all i get is the 2 flashing led's the cube never boots into avr mode. if i program the cube with the main.hex and main.eep from step 48, everything works fine. I think that there may be something in the code not letting it return 1 in the bootwait function. is there anyone that can confirm or send me a zipped up version of the file above with the correct code?

Feb 21, 2012. 7:58 PMtarPancake says:
hmmmm.... when i compile in linux, all is good :)

I am thinking that my winavr setup is bad. maybe crlf? lf? cr?

anyway, dual booted into linux, edited the source and compiled first time no errors and programmed the chip with no problems either.
Feb 5, 2012. 7:14 PMchaserled says:
(removed by author or community request)
Feb 6, 2012. 11:49 PMtriumphtotty says:
Hi.  You need to burn the fuses to tell the ATmega32 to use the external crystal.  A new ATmega32 is set to run at 1MHz using its internal clock.  You don't need to compile the code to program the ATmega.  Just download the text.hex file first from around Step46 and use avrdude from the command line.  You are using the same programmer as Chr's, so the commands are exactly as in this Instructable.  Set the fuse bits carefully as in Step 45, then upload the test.hex and run it.
Feb 12, 2012. 11:13 PMchaserled says:
i did now the cube run test one by one led and the next step i want to play around with the software but i did not sure how to set up the usb convert to serial 9 pin cable and i still try to find the way to make it work if u can help me i really appreciate i use crywin on win7 so how i support to setup the usb convert to 9pin serial port
Feb 13, 2012. 12:27 AMtriumphtotty says:
I cannot find any details on crywin. You should simply have to edit the serial port name in cube.c to whichever COM port you are using. The line is: char *tty_path = "/dev/ttyUSB0"; /dev/ttyUSB0 is a Linux name for the RS232 port. In Windows it will be COM1, or COM4 or COM12 or something like that. Use Hardware Manager to find the serial port and bring up its properties to see which port is being used.
Feb 13, 2012. 11:35 AMchaserled says:
I can't find the file name cube.c Trium i download the ledcube_8x8x8-v0.1.2.tar.gz and unzip i see draw.c, main.c etc but not cube.c
Feb 13, 2012. 12:23 PMtriumphtotty says:
The PC code is in a separate step. Around step 60 I think. You use the PC code to control the cube via the RS232 interface.
Feb 13, 2012. 11:17 AMchaserled says:
(removed by author or community request)
Feb 13, 2012. 12:01 PMchaserled says:
sorry this image more better
Feb 13, 2012. 12:06 PMchaserled says:
sorry my bad
Feb 13, 2012. 11:11 AMchaserled says:
Hi triumphtotty i was follow the intruction to burn fuse by usbtiny ,the process was suucessful but when i remove the jumper from the usbtiny it said the fuse was change! so when i install the jumper back it be come find look at this image
Jan 19, 2012. 2:32 PMchaserled says:
Hi Chr can u help me how to identify the programmer, this is my programmer http://www.ebay.com/itm/New-Development-Board-Kit-ATMEL-AVR-Atmega16-Mega16-/270745443529?_trksid=p5197.m7&_trkparms=algo%3DLVI%26itu%3DUCI%26otn%3D4%26po%3DLVI%26ps%3D63%26clkid%3D5728950572093077102
i'm have troubdle to detect it please help
Jan 20, 2012. 3:15 AMtriumphtotty says:
Hi there!

That isn't a programmer board.  It's a development board which allows you access to the PORTA-D pins on the ATmega16 either via the IDC connectors, or directly to the included LEDs and switches via the jumpers on the board.

As far as I can see, the USB port is ONLY used for powering the board.  Be very careful if you are building the LED cube, as it can draw around 1A or so, and USB1.1/2.0 spec only allows for 500mA of current, so you could blow the USB port on your PC if you attempted to only rely on USB power.  A cheap 2A/5V power brick connected to the power connector, or a salvaged PC power supply will work as per Chr's instructions.

You need to buy an ISP programmer, e.g. a USBasp or USBtinyISP to program the microcontroller.  This will connect to one of the two 10-pin connectors at the "left" edge of the board as shown on eBay.  One of these is a JTAG port and the other is the ISP port.  You will need to use the ISP port.

Hope this helps!
Jan 24, 2012. 10:58 AMchaserled says:
thankyou very much Chr your help is really pleasure to me ,
Jan 21, 2012. 8:27 PMalahamm says:
What´s this "ledcube_8x8x8-v0.1.2.tar.gz" for?
No explanation on that.
Jan 22, 2012. 7:47 AMtriumphtotty says:
That's the complete source code for the 8x8x8 cube. You need a C compiler (avr-gcc) to build the code. Use WinAVR with windows or get avr-gcc under Linux.
Jan 10, 2011. 6:49 PMemcniece says:
Is anyone else having trouble downloading this file? All I get following the link is a .tmp file...
Jan 17, 2011. 5:16 AMchengpeng19851005 says:
i have the same problem,i don't know why,may be the source file is a .temp file
Dec 19, 2011. 3:06 PMemcniece says:
Oh, they probably did it to get around something. Download it and rename the extension to .tar.gz, or just save it with the .tar.gz extension... it'll open just fine.
Dec 19, 2011. 2:22 PMhightekrednek2396 says:
you have to save as the file format unless u use mozilla then it should come out right
Feb 10, 2011. 9:26 AMadil.ali2010 says:
hi friend
i have a ardino bord for atmaga328.
can i use for this is ie atmaga3216pu.
Jan 6, 2011. 3:17 PMlpaulson87 says:
I ended up purchasing a ATMEGA324P-20PU-ND (20Mhz rather than 16Mhz) will this give me problems?
Jan 7, 2011. 3:34 PMHelder4u says:

Since it  works with an external crystal frequency there should be no problem.
I have not the data sheet.
There should be some specs for operating frequency range with Your Atmega..

Here it is:

http://www.atmel.com/dyn/resources/prod_documents/8011S.pdf

There states that it is operational from zero to 20 MHz ! :)

Good Luck!
Jan 7, 2011. 4:20 PMlpaulson87 says:
Makes sense, thanks.

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