If you have an Orangutan or 3pi Robot or wish to use the Pololu AVR C/C++ Library for some other reason, we recommend following the Pololu AVR Programming Quick Start Guide instead of this tutorial.
To program AVRs in Linux using the Pololu USB AVR Programmer, you will need to install four software packages, which can be downloaded from their respective websites. In Ubuntu Linux, these packages are provided in the “Universe” repository.
Once these packages are installed, you will be able to compile C programs for the AVR with gcc to produce hex files. These hex files can be loaded on to your AVR using avrdude and a programmer.
We will not go into the details of writing C programs for the AVR here, but, as an example, we will show you how to use your Linux computer and the USB AVR Programmer to make an LED connected to PD1 of an AVR blink. On any of the Orangutan robot controllers and the 3pi Robot, this program will blink the red user LED. If you want to program an AVR that does not have an LED connected to pin PD1, the LED-blinker code in this tutorial will have no visible effect.
If your device is an ATmega48, ATmega168, or ATmega328P, download the corresponding archive below:
If your device is not one of the above, you will need to download one of the above archives and modify the makefile to use your particular device.
Unpack the archive on your Linux computer. Copy the file
Note: You will probably want to edit BlinkLED.c slightly if the clock frequency of your AVR is not 20 MHz. F_CPU should be defined as the clock frequency of your AVR in units of Hz. If you do not make this change, the timing of delayms() will be off, but the LED will still blink.
At this point, you should be ready to compile the example program and load it on to the AVR. Plug in the programmer and type make. You should see output like this:
This output indicates the AVR was successfully programmed. The LED connected to PD1 of your AVR should now be flashing! Note that if you are trying this on a 3pi robot and you have not yet soldered in the optional through-hole LEDs, the flashing LED will be on the bottom of the robot. If there was a problem, please see Troubleshooting (Section 8) for help identifying and fixing it.