AVR Programming Tutorial: Downloading Programs

0. Make sure you've installed the necessary software.

Mac: CrossPack
Windows: WinAVR

Important Note for people running Windows: on Windows you will also have to install the driver for the USB programmer. If the driver does not successfully install automatically after you plug in the programmer, try downloading the latest libusb driver from here.

Unfortunately Windows 7 does not currently support the AVR ISP programmer we will be using.

For windows Vista 64, you need to first install AVR Studio 4. then install WinAVR 20100110. Then, download msys-1.0-vista.zip and put the unzipped file into your winavr/utils/bin directory.

1. Get your materials together.

2. Download some code.

Download and unzip ATtiny85.zip, which contains all of the files you'll need. Put the ATtiny85 folder on your desktop.

3. Open up a terminal window, a window that allows you to type out commands to send to your computer.

On a Mac, go to the Applications->Utilities folder and open Terminal.app.
On a PC, go the the Start menu and select Run. Then type cmd in the text box that pops up.

4. Navigate to the code folder within the ATtiny85 folder or "directory".

On a Mac, type the following command: cd Desktop/ATtiny85/code
The cd stands for "change directory".

5. Plug in your programmer and attach your circuit to your computer.

Here is the pin layout diagram for the ATtiny85 chip. The miniature computer that we'll be using. The diagram is from the ATtiny85 datasheet:



The first important thing to know is how to orient the chip to the diagram. We need to know which way is up. If you look closely at the chip you will see a small dot in one corner. This dot indicates the top of the chip. When you match your chip to the diagram, the dot should be in the upper left hand corner of the chip. Like so:



The diagram also shows the different functions of each leg of the ATtiny85 chip. To program the chip--to tell it what to do--we need to attach certain legs to our programmer.

Clip the programmer to your circuit, attaching the labeled alligator clips to the appropriate legs of the chip. Refer to the diagram above and follow the traces of your circuit. We need to attach + (also called "VCC" or "power" and usually colored red), - (also called "GND" or "ground" and usually colored black), RESET, MOSI, MISO, and SCK. Here's an example showing the programmer attached to a paper circuit



IF YOUR CHIP IS GETTING HOT AFTER YOU ATTACH IT, UNPLUG EVERYTHING IMMEDIATELY. THIS MEANS YOU HAVE A SHORT & YOU'RE FRYING YOUR CHIP & MAYBE THE PROGRAMMER TOO.

6. Program your chip.

Type the following command in Terminal: make clean && make && make install
If all goes well, the LED on your fabric circuit should begin to blink.

7. Open the blink.c program file.

Browse to the ATtiny85 directory, open the code folder and double click the blink.c file to open it in a text editor.

Now we're ready to start writing our own program...

AVR Programming Tutorial Part 2