If you want to use an inexpensive ATmega168 or ATmega328p for your project, but you want the simplicity of the arduino code and codebender, this tutorial will guide you through!

A brand new ATmega microcontroller does not come preconfigured to use with Arduino code. So to use one of these you normally need a high cost ATMEL ISP programmer to burn the Arduino bootloader into your ATmega. Thankfully there is an alternative way, using an existing Arduino board as an ISP.

Step 1: What you will need

-A breadboard

-An Arduino board (i.e. Arduino UNO)

-The ATmega microcontroller you want to program (ATmega 168/328)

-An FTDI basic board or FTDI cable

-A 16MHz crystal

-A 10k resistor

-Two 18 to 22 pF (ceramic) capacitors

-An 100 nF (ceramic) capacitor

The Arduino board will be needed only once, to burn the bootloader to the ATmega and the FTDI will be needed each time you want to reprogram your ATmega.

Step 2: Connecting the ATmega to the Arduino

On the breadboard we have the standard standalone ATmega setup. Note that we use the 2 capacitors of 18-22pF. We also need to connect 4 cables to the Arduino pins 10-13 to use it as a programmer.

Step 3: Program your Arduino

Thanks to codebender this is a piece of cake! Under the code below, select your Arduino device, the correct port, and click “Run on Arduino”.
(If you do not have the codebender plugin in your browser, under the code below, you will see a download/install link)

Step 4: Burn the bootloader to the ATmega

For this step we need to go to the codebender website from the following link: https://codebender.cc/static/burn_bootloader

Select “Arduino Diecimila or Duemilanove w/ ATmega168” if you have an ATmega168 or “Arduino Duemilanove w/ ATmega328” if you have an ATmega328, then select “Arduino as ISP” and the serial port of your Arduino. Finally click “Burn Bootloader”

Step 5: Programming the ATmega

Now you have an easily programmable ATmega microcontroller for your embedded projects.

To program this ATmega you need the FTDI basic board or FTDI cable, and the capacitor of 100nF for the reset pin. In the above pictures you see an FTDI cable connected to the ATmega and a Fritzing sketch with an FTDI basic board.

I have included an LED (with a 220 Ohm resistor) on pin 19 of the ATmega (corresponds to the Arduino pin 13).

Test it now with the "blink" example!

at this link you will find the mapping of the arduino pins for the ATmega 168/328 microcontrollers

<p>hi sir can i install bootloader using my ftdi232rl usb to ttl serial adapter module in my blank atmega328</p>
<p>If the ATmega is blanc you need a programmer to burn a bootloader. the FTDI chip is not a programmer, it is just a usb to serial converter.<br>A programmer uses the SPI pins to burn the program into the ATmega. :)</p>
<p>Actually you don't need to go to all that effort to get the Arduino Bootloader installed on a virgin AVR microcontroller. The Arduino IDE tool downloadable from &lt;http://arduino.cc/en/main/software&gt; and includes tools to install the bootloader, make your own sketches, and has examples that show how to make and use a simple 3-resistor AVR programmer for the PC parallel port. It also has code examples and supports many other AVR programmer devices.</p>
<p>I didn't know that! Thank you very much!</p><p>But if someone has a laptop or a newer computer he does not have this option.. I just checked the computers in my house, and only the oldest (8years) has a parallel port.</p><p>Nice for those who have a parallel port and parallel cable and do not have an existing arduino board! :)</p>
<p>Hi, can i upload standar firmata on this atmega?</p>
<p>you can upload everything that works with a standard arduino board that has the same ATmega onboard <br>:)</p>
<p>This is great! Thanks for sharing and welcome to the community! </p>

About This Instructable




More by Berdux:Program an ATmega168/328 with codebender 
Add instructable to: