Upload the program to the ATMega328p

The ArduinoISP file

In the Arduino IDE, you can find an entry named ArduinoISP under File > Examples. This sketch must be uploaded onto your programmer Arduino. Before you upload it, though, we need to change one line in the file. The Arduino IDE won’t let you save changes to this file, so you’ll have to open it in an ordinary text editor.

Find the definition of void heartbeat() and change the delay(40) (on line 98) to read delay(20).

WINAVR and the Makefile

You can download WINAVR for free. It’s an IDE you can use to manage your projects, compile, and upload them. (I actually just use it for the sake of its sample Makefile. With the help of this Makefile, I use Mingw to compile and upload my projects.)

Whatever you do, find the sample Makefile in the ‘sample’ subdirectory of the WINAVR program folder. Copy it, and paste it into your own project folder. (If you haven’t used make and Makefiles before, that goes beyond the scope of this tutorial, so you’ll need to do some outside research.) There are a few adjustments we must make to this Makefile:

Find the definition of F_CPU and set it to match the speed of your clock (crystal): F_CPU = 16000000

Find the definition of MCU and set the identity of your receiving miniprocessor: MCU = atmega328p

Find the definition of AVRDUDUDE_PROGRAMMER and set the identity of your programmer (Arduino): AVRDUDUDE_PROGRAMMER = stk500v1

Find the definition of AVRDUDE_PORT and set it to the port where your programmer Arduino is attached to your computer (for me, always COM8): AVRDUDE_PORT = com8

Compile and Upload

Using the (altered) sample Makefile, we have only to make use of two tasks. In WINAVR, under Tools, select Make (all). This compiles the project to the appropriate format for the miniprocessor. Then under Tools, selec Make (program). This will upload the program onto the receiving miniprocessor.

2 Responses to How to use Arduino as AVR Programmer (for ATMega328p)

Hi, I follow the tutorial step by step, I made the LED connected to pin9 on the Arduino to blink, but not the LED that was connected to the chip (PB1) to blink. Does the standalone chip need a bootloader?