Program ATmega 328 Using Arduino (Arduino As ISP)

30,107

80

14

Introduction: Program ATmega 328 Using Arduino (Arduino As ISP)

About: Maker, Electronics enthusiast. Studied B.tech Electronics and Communication Engineering. Studies M.tech Robotics And Intelligent systems.

Arduino is nowadays an easy tool for e-hobbyists .As an open platform and a "ready to use" circuit, everyone follows various arduino boards for realization of embedded designs. But sometimes it is difficult and unaesthetic to use such large board as the basic circuit of our project or product, such as making a home automation system using an arduino board'll not be professional . Any arduino board consists of two basic blocks namely the programmer and the microcontroller . The microcontroller is nothing but a standalone microcontroller (Atmega328 in arduino uno) and the programmer is the programming circuit which do the programming of our microcontroller.

When we are making an application level electronic product, we don't need the entire arduino in the design. Only we need the microcontroller programmed as per our application and we don't need the programming circuit of the arduino board. So, in this instructable we gonna program a 328 microcontroller for led flashing and using the microcontroller alone on a breadboard.

Step 1: Bill of Materials

1. Arduino Uno.

2. Breadboard.

3. USB A to B cable.

4. ATmega328 microcontroller.

5. LEDs.

6. 22 pF capacitors.

7. 16 Mhz crystal.

8. 9V battery.

9. Jumper wires.

Step 2: Bootloading the Microcontroller

In non technical words, bootloading is nothing but making a bridge of communication between the arduino board and the microcontroller. The microcontroller 328 that we buy in market may or may not be bootloaded. I it is already bootloaded, then we can directly use it with the arduino otherwise we have to bootload it first. Bootloading can be done with the same arduino uno.

1. Fix the 328 on a breadboard.

2. Connect the crystal to the 9th and 10th pins of the 328.

3. Connect two 22 pF capacitors to each of the two legs of crystal and ground them.

4. Connect pin no: 7 and 20 to a 5V pin of arduino.

5. Connect pin no: 8 and 22 to ground of arduino.

6.Connect pin no:10 of arduino to the pin no:1 (reset) of 328.

7. Connect pin no:11 of arduino to the pin no:17 of 328.

8. Connect pin no:12 of arduino to the pin no:18 of 328.

9. Connect pin no:13 of arduino to the pin no:19 of 328.

Now connect the arduino board to the computer

The arduino in powered up also the 328 on breadboard is powered up.

The circuit is ready and we have to bootload , open the arduino IDE for that.

From MENU select Tools>Programmer>arduino as ISP

Then select Tools>Burn bootloader

After a few seconds, the 328'll be bootloaded and we can easily program it with the arduino board.

Step 3: Programming

Remove all the connections from arduino board to the breadboard we've done for bootloading.

We need some new and a few connections for programming 328.

The new connection steps are as below,

1. Connect Vcc and Gnd from the arduino board to the breadboard microcontroller.

2. Connect the RESET pin of arduino board to the pin number 1 of ATmega 328.

3. Connect the Rx pin of arduino to the pin number 2 of 328.

3. Connect the Tx pin of arduino to the pin number 3 of 328.

Now we've to make some changes in the IDE also , as follows,

1. From MENU , select Tools >Board > "Arduino Duemilanove or Diecimila"

2. now select ,Tools > Processor > ATmega328

Now the entire programming setup is ready

write the program as usual, click "upload"

The program'll be uploaded to the microcontroller.

Remove all the arduino connections, provide a separate 5 VDC power supply to the breadboard and we've an independent 328 microcontroller in action.

Step 4: An Important Pitfall

In the arduino IDE , pin number 5 means the fifth pin of the arduino board not the fifth pin of 328 microcontroller.

It is actually 11th pin of the 328.

Since we are coding for a standalone 328, we've to put keen attention in accessing the I/O pins.

So, access 11th pin of the 328, we've to write in the code "5" instead of 11.

All the 18 I/O pins of 328 can be accessed like this.

So I'm attaching a table which describes everything about coding the I/O pins.

Step 5: Demo Video of Blinking Led on Breadboard

Have Funnnnnn........<3

Arduino Contest 2016

Participated in the
Arduino Contest 2016

Be the First to Share

    Recommendations

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    14 Discussions

    0
    ejour
    ejour

    Question 3 months ago

    I dont have an option for "atmega328 on breadboard" any advice?

    0
    SHAMSUDHEEN MARAKKAR
    SHAMSUDHEEN MARAKKAR

    Answer 3 months ago

    I cant undersatand! Can you make it clear?

    0
    ejour
    ejour

    Reply 3 months ago

    i bought some chips with the bootloader in them. I followed your directions to program the standalone 328p. under tools board type i dont have an option for atmega 328 on breadboard.
    When i wire up the board to your specs for programming and attempt to upload the program, it wont take. What programmer am i using, and do i upload or upload using programmer

    0
    CRTstuff
    CRTstuff

    6 months ago

    The bootloader I'd a bridge of communication between the MCU and the Arduino.

    That must be the best and most simple explanation of a bootloader I've ever heard!

    0
    rukun.gupta.rg
    rukun.gupta.rg

    Question 7 months ago on Introduction

    I recently got a arduino Uno board. But the pin 6 of atmega328 Ic is not connected to board. But when I did blinking led experiment with digital pin 4 it was working fine. I'm pretty sure that pin 6 is not connected with board. And on internet it was written that pin 6 of atmega328 is digital pin 4 of Arduino Uno board. Then how is it working? Should I replace the board or just work with it only?

    0
    Matthew.sm1990
    Matthew.sm1990

    11 months ago

    So i did everything but i keep getting uploaded error i have metro 328 and mega 328 please help

    0
    Yasith Silva
    Yasith Silva

    3 years ago

    Hi, What about the IC in the board. Do u need to remove it when programming? If so what to do with the new board which they have put a surface mount ic

    0
    SHAMSUDHEEN MARAKKAR
    SHAMSUDHEEN MARAKKAR

    Reply 3 years ago

    We cannot do this with the SMD version of the Arduino. Because we need to remove the IC from the board.

    0
    RaduL5
    RaduL5

    3 years ago

    Hi, what about the AtMega 16 A ? Can i program it like that ? Thanks

    0
    Cobus089
    Cobus089

    3 years ago

    Hello !

    Thanks a lot for this brilliant howto !

    I have questions, though.

    1. Other howtos advise the use of an ATmega328-PU microcontroller. What variation of the ATmega328 do you advise ? Why ?

    2. In the following video <https://www.youtube.com/watch?v=30rPt802n1k> "How-To: Shrinkify Your Arduino Projects", an Arduino is used as an ISP to program an ATtiny85. No bootloader install is mentioned. Is it really necessary to burn a bootloader to do the same with an ATmega328 ? Why ?

    3. My board is a Genuino Uno R3. I would like my standalone microcontroller to be as close to my Uno R3 as possible. Your step 3 advises to choose "Arduino Duemilanove or Diecimila" board. Should I switch to "Arduino/Genuino Uno", or stick to your howto ? Why ?

    Again, thanks a lot !

    Cobus.

    0
    SHAMSUDHEEN MARAKKAR
    SHAMSUDHEEN MARAKKAR

    Reply 3 years ago

    1. The ATmega 328, P and PU only differ in their package and power consumption. The PU type is a low power consuming one which you can use in some portable applications .

    2. You should burn the bootloader for programming the 328 with arduino. But in the case of ATtiny microcontrollers, what only you need is installing the ATtiny support files with the arduino IDE and you can directly program the ATtiny.

    3. For programming 328 using arduino Uno board, one should select Duemilanove or Diecimila instead of Genuino uno even though the board is Uno .

    Sorry for the late reply....... :)

    0
    Cobus089
    Cobus089

    Reply 3 years ago

    Hello,

    Thank you for your answers.

    Concerning my question #2, I found an interesting website.

    <http://www.notesandvolts.com/2013/01/fun-with-arduino-arduino-as-isp.html> wrote :

    Since we are using the SPI interface to program the chip, we don't need the Bootloader.

    It also wrote that burning a bootloader (and then erasing it) was an easy way to set the fusebits correctly.