Arduino IDE is designed to program Arduino boards featuring an AVR microcontroller with an Arduino bootloader. But Do you know that the same Arduino IDE can be used to program other Atmega microcontrollers, even without a bootloader?.

Arduino Mega

Arduino Mega

Well it can. But you need an extra AVR programmer like USBASP. This method has many advantages like extra program memory space of about 2 Kb due to not using a bootloader, short prototyping time compared to coding in C. Moreover, one need not buy the Arduino board for every project, as we can use the cheaper Atmegas.

I tried Atmega 8 and Atmega 32. Both of them works flawless with the Arduino IDE.The hardware is simple and consists of just the power supply, a crystal (8MHz for atmega 8 and 16MHz for Atmega32 etc. The Atmega to Arduino pin mapping for both of them is given below

Arduino-To-Atmega8-Pins

Arduino-To-Atmega8-Pins

Arduino to Atmega32 pin map

Arduino to Atmega32 pin map

The Arduino IDE uploads sketches default using the bootloader and through the serial port. Now we have to change it to the USBASP. This can be done by editing the file named programmers.txt located at ~/arduino-xxx/hardware/arduino directory. We have to add an entry corresponding to our USBASP to the end of the file named programmers.txt.

ie

usbasp.name=usbasp
usbasp.communication=usb
usbasp.protocol=usbasp

Now we have to edit the file named boards.txt located in the same directory to include our custom boards.We have to add two entries, one for Atmega 8 and the other for Atmega 32. Add the following to the end of Boards.txt

##############################################################

atmega32.name=ArduinoMega32
atmega32.upload.using=usbasp
atmega32.upload.protocol=usb
atmega32.upload.maximum_size=32768
atmega32.upload.speed=38400

atmega32.bootloader.low_fuses=0xff
atmega32.bootloader.high_fuses=0xdf
atmega32.bootloader.extended_fuses=0x00
atmega32.bootloader.path=atmega
atmega32.bootloader.file=ATmegaBOOT.hex
atmega32.bootloader.unlock_bits=0x3F
atmega32.bootloader.lock_bits=0x0F

atmega32.build.mcu=atmega32
atmega32.build.f_cpu=16000000L
atmega32.build.core=arduino

#################################################################

atmega8.name=ATmega8 @8MHz

atmega8.upload.using=usbasp
atmega8.upload.protocol=usb
atmega8.upload.maximum_size=8192
atmega8.upload.speed=38400

atmega8.bootloader.low_fuses=0xef
atmega8.bootloader.high_fuses=0xc4
atmega8.bootloader.path=atmega8_
atmega8.bootloader.file=ATmegaBOOT.hex
atmega8.bootloader.unlock_bits=0x3F
atmega8.bootloader.lock_bits=0x0F

atmega8.build.mcu=atmega8
atmega8.build.f_cpu=8000000L
atmega8.build.core=arduino

Now we have to add the some more files. Download this and extract it. Replace the cores directory (~/arduino-xxx/hardware/arduino/cores) with the downloaded folder. Thats all.. you are done. Now you can find two more entries correponding to Atmega 8 and Atmega 32 under your tools>boards option. Select the one of your choice and code…

The code generated using Arduino IDE is much less efficient than the one generated using assembly or even C. It takes more machine cycles to execute. But the main advantage is that the development time of a project will reduce drastically. It is due to the huge number of libraries available for arduino. I built my own versions of Arduino clones on some perf boards and used alot of berg strips. It may feel awkward but it does help very much in rapid prototyping and debugging. below are some photos of my arduino clones.

Arduino clone using Atmega8

Arduino clone using Atmega8

Arduino clone using Atmega 8

Arduino clone using Atmega 8

Atmega32 variant. It also features a L293D motor driver

Atmega32 variant,closeup

Berg Strips with labelled connectors

Berg Strips with labelled connectors