Introduction: Using Atmega32 With Arduino IDE

Over time I have used all kinds of Atmel microcontrollers in various projects.

One of the most suitable was ATmega32. I have a small collection of development boards for Atmega32/16, some bought as-is, some made on stripboard.

Although the original Arduino boards offers a pleasant experience and a rapid development of the projects, when it was necessary to "extract" these projects to give them final shape I hit the well-known problem: arduino board must be "locked" in the project.

It is not only the price. Although a microcontroller in thru-hole package is significantly bigger than SMD version, it is still much smaller than an Arduino board.

And still I want to use the Arduino IDE to benefit from the collection of (very well made) (ready-to-use) libraries.

So I gathered together information useful for this purpose.

Step 1: Things You Will Need:

  1. Atmega32 microcontroller. :)
  2. Programmer (any programmer recognized by Arduino IDE). I use the USBasp programmer.
  3. Minimal setup for power-up Atmega32 microcontroller (breadboard, stribpoard or a classical development board).

We do not need all, photos above are for exemplification only.

Step 2: Software Set-up

  1. Download zip file attached to this instructables.
  2. Locate file boards.txt in arduino folder ...arduino-1.5.2\hardware\arduino\avr\boards.txt
  3. Append information from zip archive boards.txt to original boards.txt
  4. Make a folder named mega32 in ...arduino-1.5.2\hardware\arduino\avr\variants
  5. Copy file pins_arduino.h from the zip into folder created at step 4.
  6. Start Arduino IDE and select board.
  7. Select programmer

Later edit:

I removed link to github projet where I originally found. As long as there source changed and not fit this instructable.

After a message from the author: Eric Conner, I put back link to github project where I originally found this library:

Note: Zip file attached to this article is an older version of above library. This will work as this instructable was written.

Over time, after some feedback I noticed that source from github has changed.

Also, in comments you will see references to some errors, and how to to correct it.

This article and answers from comments is relate to version attached here, not github (newer) version.

Step 3: Done.

It's done.

Now you can try some simple examples that are already in Arduino.

Be very careful about correlation between ARDUINO pin and microcontroller pin.

Here is blink example: Files->Examples->Basics->Blink

Pin13 Arduino == Pin19 (PD5) Atmega32

  Turns on an LED on for one second, then off for one second, repeatedly.
  This example code is in the public domain.
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second

After some comments I found two errors in the file pins_arduino.h

So I’ll post here the errors and correct values.

erroneous definition of SCL and SDA

const static uint8_t SDA = 8; //wrong
const static uint8_t SCL = 9; //wrong

must be changed in:

const static uint8_t SDA = 17; //correct
const static uint8_t SCL = 16; //correct

Since I am not the author of the project on github, it is subject to change beyond my control.

So please use code attached to this instructable and make above modifications.


For Serial library to work properly must be made following changes to the file HardwareSerial.cpp
In ...\arduino-1.5.8\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp

will replace:

#if defined(__AVR_ATmega8__)
	config |= 0x80; // select UCSRC register (shared with UBRRH) 


#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega32__) || defined(__AVR_ATmega16__)
	config |= 0x80; // select UCSRC register (shared with UBRRH) 

See also:


Abraar Sameer made it! (author)2017-05-12

Hello Silvius,

I uploaded a simple blink sketch using arduino as ISP to blink an LED at PD7 with a delay of 250 ms. But the delay seems too long, about 4000 ms, which is 16x the amount I needed. Is there any problem with timing? How to solve it?

Silvius made it! (author)Silvius2017-05-12

Put some fusebits according with your osc... here are my fuse bits... read from working atmega32 with 16MHz quartz and USBASP. Working in Arduino IDE and AVR Studio:
low fuse :DE
high fuse: D9

ChandanaG2 made it! (author)2017-03-22

hi Silvius

how to boot loader atmega32a with Arduino mega2560 board ?

HarendraK3 made it! (author)2016-09-03

hi Silvius!!

i m getting error of missing 'upload.tool'
configuration parameter, when uploading the code to Atmega 32 using
usbasp as programmer...plz help me in resolving the problem.

VishalM45 made it! (author)2016-08-16

error while burning bootloader: missing 'bootloader.tool' configuration parameter

i am getting these error while i am trying to put bootloader in atmega32 and i am using usbasp as programmer, plz help me whr i am doing mistake

Silvius made it! (author)Silvius2016-08-16

There are no bootloader in this setup. Just use USBASP to upload your code.

tejanihiren1991 made it! (author)2016-07-29

Hello Silvius, Great Job man, i follow your step and first Toggle all pins of my atmega32 and it work,then after i use i2c protocol for data read write it also work but when i try to use SPI protocol MOSI and slave select pin are toggle and SCK pin of SPI not toggle it continue high no change in that pin ,can you please provide some information on SPI or give example code so it's help me. Thank you.

VishalM45 made it! (author)VishalM452016-08-16

error while burning bootloader: missing 'bootloader.tool' configuration parameter

i am getting these error while i am trying to put bootloader in atmega32 and i am using usbasp as programmer, plz help me whr i am doing mistake

indiamtech made it! (author)2016-08-12

hii silvius, nice work brother, i made that on arduino 1.6.9 ,but i install that atmega32 board as per ur other instuctable ,that is "ATmega dip-40 in arduino ide 1.6.4." by simply providing ur link in preferences. now it shows error to softwareserial library as shown in pics.i am making this clone for the home security that i want to use gsm module.can u provide solution for this problem.

thank you.

Silvius made it! (author)Silvius2016-08-12

I think that softwareserial library use PCINT interrups. Atmega32/16/8 don't have PCINT at all. You can try same method as you mention above, with ATmega 1284... but Atmega1284 already have 2 serial... so no need to use software serial (unless you need 3 or more serials...)

Or you can try an old version of software serial library with atmega32 and old version of arduino ide ... 1.0.xx.

These are solutions that I see at the moment... maybe someone else come up with other solutions ...?

TrevorL26 made it! (author)2016-05-24

I tried following these instructions but when I tried saving the modified 'boards.txt' it said that i was not allowed to. I am an admin on this computer. I tried saving the file somewhere else and deleting the original 'boards.txt'. I then transferred the new version into the correct place. when I ran the program it said that the 'boards.txt' file was invalid. what am I doing wrong?

Silvius made it! (author)Silvius2016-05-24

I can try to guess... I do not know what operating system you use and which version of the Arduino IDE... this instructable was written before the "Arduino 1.6.xx". Use this article only with Arduino 1.5.xx (or lower)

For newer versions I think is better to read an follow this instructable:

I use Arduino IDE 1.6.7 in Linux Ubuntu 16 (also tested with windows 7).

nillkanth made it! (author)2016-04-01

Yes, I have done these. Thanks

TomO26 made it! (author)2016-03-20


I'm having a problem with pin interrupts using this set-up

I can get INT0 and INT0 to work correctly, enabling the internal pull-up resistors and then using:

attachInterrupt(digitalPinToInterrupt(10), footOne, CHANGE); // Foot One - Pin 10

attachInterrupt(digitalPinToInterrupt(11), footTwo, CHANGE); // Foot Two - Pin 11

but if i try the same for INT2:

attachInterrupt(digitalPinToInterrupt(2), footThree, CHANGE); // Foot Three - Pin 02,

I the interrupt never gets triggered, despite each pin being set up in the same way with the same debouncing circuit.

Any ideas how to get INT2 to work correctly?


Silvius made it! (author)Silvius2016-03-21

There is no quick solution to this ... I just did some tests...

It seems that the problem is in arduino core files WInterrupts.c and wiring_private.h, there should be added support for ATmega32/16, but I can't do that in so little time.

Anyway It's interesting "bug"... I never feel need to use INT2 until now... When I needed more external interrupts I moved to ATmega1284 and i use PCINT...

I think there are some modified cores ... but i don't now what are their limits.. try to study "Sanguino", "Bobuino", "Mighty-1284P", I know about them, but I never study in detail...

I try to not modify too much default core files... to be easy to remake when arduino cores are upgraded... so I look inside WInterrupts.c and wiring_private.h but I can't see a quick solution...
TomO26 made it! (author)TomO262016-03-21

Hi Silvus, Thanks so much for getting back to me!

For the particular application I managed to find a work-around:

(used the same interrupt pin for 2 of the switches, and send the output of one of the switches to a different digital pin, so that during the interrupt, the digital pin can be read and the correct switch chosen)

But next time if i need lots of interrupts I'll switch to a different chip! (my choice of the 32 was fairly arbitrary in this case as I'm new to micro controllers, all I knew was i needed more pins that the 328p)

Silvius made it! (author)Silvius2016-03-21

a quick and dirty solution to use INT2:

put this in setup()

MCUCR |= (1 << ISC2);
GICR |= (1 << INT2);

and make a function exactly like this:

// code for int2 ....

you can put this function before.. or after main function (I tested with function after main()... )

so you can write something like this:

// code for int2 ....

I tested right now and work ...

TomO26 made it! (author)TomO262016-03-25

Thanks again for your help.

I've been coming across an other issue, digital pins 18 19 20 & 21 aren't working properly.
I can't even get them to blink an LED

if i use the basic arduino example blink: it works correctly for the digital pins such as 15 16 17 22 & 23, but if I chance the pin in the program and on the breadboard, nothing happens. any ideas?


const int LED = 18;

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin as an output.

pinMode(LED, OUTPUT);


// the loop function runs over and over again forever

void loop() {

digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second


Silvius made it! (author)Silvius2016-03-25

those pins have dual function I/O and JTAG. you must disable JTAG...

or by setting fusebits or by program... see this for more info:

for begining you can put this in setup function:

MCUCSR = (1<<JTD);
MCUCSR = (1<<JTD);

twice is not a mistake ...

Have fun!

TomO26 made it! (author)TomO262016-03-25

Thanks! That's worked perfectly! hopefully I won't need to ask any questions as I've got all my inputs and outputs working!

Maahnaaa made it! (author)2016-03-21


im geting this error

Library can't use both 'src' and 'utility' folders. Double check C:\Users\Touresina\Desktop\New Folder (2)\arduino-1.6.8\hardware\arduino\avr\libraries\Wire

Error compiling for board ATmega32.

please help me


Silvius made it! (author)Silvius2016-03-21

I noticed that you use 1.6.8 ... I thought the latest version 1.6.7 ... :)

... this instructable was written before the "Arduino 1.6.xx". Use this article only with Arduino 1.5.xx (or lower)

For your version I think is better to read an follow this instructable:

Gautam1807 made it! (author)2016-02-19

i have made changes like you said in ide files but now i am getting this error...

Arduino: 1.6.7 Hourly Build 2015/12/17 04:47 (Windows 8.1), Board: "Arduino/Genuino Uno"

Property line '?# See:' in file E:\Robotics\arduino-nightly-windows\arduino-nightly\hardware\arduino\avr\boards.txt is invalid

Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Silvius made it! (author)Silvius2016-02-20

Hm... this instructable was written before the "Arduino 1.6.xx". Use this article only with Arduino 1.5.xx (or lower)

For your version I think is better to read an follow this instructable:

Last article was written for 1.6.4 but working even with 1.6.7. I use this in Arduino 1.6.7 on Ubuntu (also tested on windows 7 64bit). Inside are defined six "boards":

  • ATmega16-8MHz
  • ATmega16-16MHz
  • ATmega32-8MHz
  • ATmega32-16MHz
  • ATmega1284-16MHz
  • ATmega1284-20MHz
Gautam1807 made it! (author)2016-02-19

how to make arduino campatible circuit with this IC.

Silvius made it! (author)Silvius2016-02-19

look here: it is about any atmega dip 40 (diy minimal development board) it will work with atmega32 or atmega1284, or atmega16 ...

Silvius made it! (author)2016-01-18
There are two separate issues:

1. To install support files for Atmega32 in Arduino IDE.

2. To make USBASP work in your OS ( in your case Win 8.1)

You can look here or here. If you have trouble we can continue there...

MirkoJ made it! (author)2016-01-17

I do have Win 8.1 and ver. 1.6.7 Arduino IDE and there is no way to get IDE to recognized Atmega32. Would there be any help, please? Thanks

TanasV made it! (author)2016-01-09

Thank you for the amazing article.

But i have little problem with serial communication over Arduino serial library. From Atmega i send word "hello" and on computer i get "+±± ʺ©Íë".

Both device are set on 9600 baud. I use Atmega32, directly connected to computer serial port from pin 14 and 15 (and GND).

Had someone a similar problem? It is even possible to use Atmel in this way?

Silvius made it! (author)Silvius2016-01-09

At the end of this instructable (end of step 3) is an update about this issue.

It is about HardwareSerial.cpp modification.

electric1981 made it! (author)2015-10-29

actually i have upgraded to windows 10 but this thing does not say that

Silvius made it! (author)Silvius2015-10-30

This article is not intended for your version of the Arduino IDE. When I was writing this article Arduino 1.6.5 not exist at all.

electric1981 made it! (author)2015-10-29

Hello silviius I keep getting errors with my arduino IDE here they are ..........
Arduino: 1.6.5 (Windows 8.1), Board: "ATmega32-8mhz"

Error while burning bootloader.


at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(


at java.awt.event.InvocationEvent.dispatch(

at java.awt.EventQueue.dispatchEventImpl(

at java.awt.EventQueue.access$500(

at java.awt.EventQueue$

at java.awt.EventQueue$

at Method)


at java.awt.EventQueue.dispatchEvent(

at java.awt.EventDispatchThread.pumpOneEventForFilters(

at java.awt.EventDispatchThread.pumpEventsForFilter(

at java.awt.EventDispatchThread.pumpEventsForHierarchy(

at java.awt.EventDispatchThread.pumpEvents(

at java.awt.EventDispatchThread.pumpEvents(


Does that make any sense ? I dont know why its not working

Jacokako made it! (author)2015-10-29

Arduino: 1.6.5 (Windows 7), Board: "ATmega32-8mhz"

Selected board depends on 'arduino' core (not installed).

Silvius made it! (author)Silvius2015-10-29

You are using 1.6.5.... this solution is for Arduino 1.5.x

There are many solutions for Arduino > 1.6.x ... One of them is here:
(this is made by me from scratch... right after 1.6.4 release, mainly
for personal use... at that time I have no choice... Since then, there
are other solutions available.)

Jacokako made it! (author)2015-10-24

Arduino: 1.6.5 (Windows 7), Board: "ATmega32-External 16mhz"

Selected board depends on 'arduino' core (not installed).

shreyask1 made it! (author)2015-10-22

Does this work with ATmega32a TQFP....??

Silvius made it! (author)Silvius2015-10-22

It should work. Just be careful with pin mapping...

For example Arduino Digital Pin0 = PB0 = PIN40 from IC TQFP...

diy_bloke made it! (author)2015-10-14

sadly my usbasp programmer isnt recognised in Ubuntu nor in Windows10 (yes installed the driver) maybe I have to make a pony programmer :-(

diy_bloke made it! (author)diy_bloke2015-10-15

yep, tried several. I think including the ones you link to. I did come across some messages though of people who, no matter what, couldnt get the USBasp recognized.
In fact both Windows 10 and Ubuntu 12.04 and ubuntu 14.4 indicate the know the device on the USB port... but the applications (IDE and codebender) just dont see it.
Thank you nevertheless for trying to help :-)

diy_bloke made it! (author)diy_bloke2015-10-15

just let me add that installing the driver in windows 10 was not the problem. That works and I see it in the device manager and windows says it is the most up to date driver, but then the applications dont see it :-)

boop12343 made it! (author)2015-09-25

I wanted to use atmega with 14.7456mhz with arduino ide.

What changes do i make to the files ?

Silvius made it! (author)Silvius2015-09-26

Try add this to boards.txt (after install other files as in instructable)



boop12343 made it! (author)boop123432015-09-26

Sorry for the trouble. Had done exactly this. My board isn't working. Worked fine with a new one

Thank You

EMA2012240 made it! (author)2015-07-29

pls i want to know how to upload my code to atmega32A after finishing it ana i did your steps correctly

Silvius made it! (author)Silvius2015-07-30

You can upload using any programmer supported in Arduino IDE (like USBasp). Just connect it to your development board. Select board and programmer from Arduino IDE menus.... and press upload button.

If you have no development board available, you can try to make one...
look here for some info/ideas:

souravg009 made it! (author)2015-06-11

I simulated Arduino sketch in proteus. this works like a charm.

Silvius made it! (author)Silvius2015-06-11


jelimoore made it! (author)2015-05-09

Hello, I am uploading the code over the SPI bus via an Arduino as programmer, but the timing seems to be off on the AT32, whether I use the internal 8mhz or external 16 mhz crystal; and the 16mhz crystal seems worse than the internal 8. Do you know why this is?