Summary of How to program a AVR (arduino) with another arduino using attiny2313 microcontroller
Summary: This article explains how to turn an Arduino into an ISP programmer using the Mega-ISP sketch (avrisp) so you can program bare AVR chips (ATmega328/168/8, ATtiny2313/13, etc.) on a breadboard or via an ISP header. It covers required parts, wiring (MOSI/MISO/SCK/RST to Arduino pins 11/12/13/10), status LEDs, uploading the sketch, and using avrdude at 19200 baud to program target chips.
Parts used in the Mega-ISP programmer project:
- Working Arduino or compatible board (BBB, RBBB, etc.)
- Target AVR chip to program (ATmega8, ATmega168, ATmega328, ATmega368, ATtiny2313, ATtiny13, etc.)
- Breadboard or board with 2x3 ISP header
- 3 LEDs (heartbeat, error, programming)
- 3 current-limiting resistors for LEDs
- Breadboard jumper wires
- 5V power connection and ground wiring
- Pull-up resistor on Reset pin of target chip
- Arduino IDE (for uploading Mega-ISP sketch)
- avrdude (to communicate with avrisp)
* you’ve got your arduino with atmega168 and you bought an atmega328 at you local electronics store. It doesn’t have an arduino bootloader
* you want to make a project that doesn’t use arduino – just a regular AVR chip (like the USBTinyISP) – you have a clean attiny2313/attiny48 etc that you want to burn firmware on.
Normally you would have to have an ISP (In System Programmer) like USBTinyISP to program your new chip. Having the arduino you can teach it to be a programmer thank to a great work done by Randall Bohn. He created Mega-ISP – an arduino sketch that works like a programmer.
Step: 1 What do you need ?
* a working Arduino (or a clone – i’m using the BBB – BareBonesBoard and a RBBB – RealBareBonesBoard by ModernDevices)
* a chip that you want to program (tested with atmega8,atmega168,atmega368, attiny2313, attiny13)
* a breadboard or a board with ISP header
* 3 leds + 3 resistors
* breadboard wires
Step: 2 Making the mega-isp programmer on a breadboard
There are two ways to connect your Arduino to program a chip.
You can plug your avr chip to a breadboard and connect 5v and GND to the respective pins (check the datasheet!) + a pullup resistor to reset and wire pins from you arduino to the chip.
These are the lines on Arduino and their function
13 – SCK
12 – MISO
11 – MOSI
10 – RST (Reset)
Or you can make a 2x3pin ISP header that you can plug into a board that provides one (another arduino board).
The pinout for the ISP header is on the third image
There are 3 leds to indicate the status of the programmer.
pin 9 – blue led – its the hearbeat of the programmer.
pin 8 – red led – indicates an error
pin 7 – green led – indicates that the programming is taking place
(i was lazy so i didn’t match the colors in my setup)
Here are the drawings made in Fritzing
You can alsa make a MEGA-isp shield. Yaroslav Osadchyy designed the shield in eagle. You can get the eagle files on his site: http://drug123.org.ua/mega-isp-shield/
Step: 3 Uploading the sketch
Download the sketch from mega-isp google code.(avrisp.03.zip at the time of writing).
Unpack it and run arduino ide and open avrisp.pde.
Upload it to your arduino board.
Heartbeat led should start beating.
Step: 4 Using with avrdude
To use with avrdude (and all GUIs that use it) you have to select the ‘avrisp’ programmer. the safest bitrate is 19200.
To test your your new atmega168 from commandline try:
$ avrdude -p m168 -P /dev/ttyUSB0 -c avrisp -b 19200
/dev/USB0 is the port that arduino is connected to my linux box (your’s may be com5). This can be checked in arduino IDE in Tools -> Serial Port.
You should get:
[kabturek@hal-9000 ~]# avrdude -p m168 -P /dev/ttyUSB0 -c avrisp -b 19200
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.13s
avrdude: Device signature = 0x1e9406
avrdude: safemode: Fuses OK
avrdude done. Thank you.
That means everything is ok.
If you get errors – check the last step.
For more detail: How to program a AVR (arduino) with another arduino using attiny2313 microcontroller
- What do I need to make the Arduino act as an ISP programmer?
You need a working Arduino board, the target AVR chip, a breadboard or ISP header, 3 LEDs with resistors, jumper wires, a pullup resistor on reset, the Mega-ISP avrisp sketch, Arduino IDE, and avrdude. - Which Arduino pins map to the ISP signals?
Use pin 13 for SCK, pin 12 for MISO, pin 11 for MOSI, and pin 10 for Reset. - How are the three LEDs used in the setup?
Pin 9 drives a heartbeat LED, pin 8 indicates an error, and pin 7 indicates programming activity. - How do I upload the Mega-ISP sketch to the Arduino?
Download avrisp.03.zip, open avrisp.pde in the Arduino IDE, and upload it to your Arduino; the heartbeat LED should start blinking. - Which programmer name and baud rate should I use with avrdude?
Select the avrisp programmer and use a safe bitrate of 19200. - How can I test that the target ATmega168 is responding?
Run avrdude -p m168 -P -c avrisp -b 19200; a successful response shows device signature and safemode fuses OK. - Can I program chips without an existing ISP like USBTinyISP?
Yes, by turning your Arduino into an ISP programmer with the Mega-ISP sketch you can program clean AVR chips. - Is there a ready-made shield option for Mega-ISP?
Yes, a MEGA-isp shield was designed in Eagle by Yaroslav Osadchyy and files are available from his site.


