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) libraries  ready to use.

So I gathered together information useful for this purpose.

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. )

Software set-up

  1. Download project or ATmega32-Arduino-master.
  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.

Atmega32 / Arduino Pinout

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

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

Note: I also published this article on Instructables.

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

Please note, since it is not my project can not correct them at the source (

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

Related posts:


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

we will replace:



Updated: April 9, 2015 — 6:11 pm


Add a Comment
  1. Just accidentally came here . Really compact and NICE instructions.
    You can make standalone projects using this information.

  2. Wow! Really helpful info. I, however, found out the attachInterrupt() arduino function does not work with atmega32 .Any help?

    1. No… attachInterrupt() is working with newer PCINT interrupt.

      Atmega32 and Atmega16 (and Atmega8) do not have this interrupt…

      The only solution is to switch to newer Atmega1284 / Atmega1284P/ Atmega644 … they have PCINT interrupt and are similar to Atmega32.

      1. I think that what I said above is not entirely true…
        It is true that ATmega32/16/8 not have PCINT interrupt (Pin Change Interrupt)…
        But I am not so sure about how this affected attachInterrupt()

        I can not give an (well documented) answer right now …
        I hurried to correct erroneous information

        The answer is somewhere in arduino-1.6.7/hardware/arduino/avr/cores/arduino/WInterrupts.c 🙂

  3. Hi Guys,

    I developed a scketch to work on Arduino Mega and I need to compile in an AtMega1284p-pu
    – Can I compile the same scketch in Atmega1284p-pu?
    – Is it necessary to change anything on the scketh? pins for example?
    – The AtMega1284p-pu is still a “virgin”, which Arduino’s bootloader is better to burn in?


    Angelo Ventura

    1. “Can I compile the same scketch in Atmega1284p-pu?” – Yes

      “Is it necessary to change anything on the scketh?” – Depends.
      You will probably need to use other pins than Arduino Mega.
      (as you can see Arduino Mega is based on Atmega 1280 or 2560 and has 54 pins)
      Atmega 1284P has 40 pins, so probabily you have to adjust your project schematics,
      and as a consequence… the code(scketch)

      “which Arduino’s bootloader is better to burn in” … my personal choice… best bootloader is without bootloader”, 🙂 … I always use a programmer (like USBASP)

      and because it is about new/ blanc microcontroller, the most IMPORTANT thing is to put fusebits according to your needs/usage…
      you can run Atmega1284 at max speed 20MHz … or you can run at other speed … 16MHz like Arduino Mega,you can use with external quartz or resonator or internal oscillator…
      there are many possibilities, you must study a good tutorial about fusebits and make your decisions about your specific project…

      And if you have more questions we can discuss further..


  4. hey hii friends i m using open hardware for atmega32 but i found mapping of adc is wrong i means if A0 is selected then actually it is A1

  5. hi. i want to monitor values on IDE serial monitor but it not working. would you help me please.

    1. I’d like to help but I have too little information. What does not work exactly?
      What kind of hardware setup do you have? MAX323… USB to serial…
      What operating system are you using? Windows… Linux… Arduino IDE version…
      It could be the drivers for USB-to-serial… or Arduino IDE version…

      1. Hello . thank you for your attention.
        i made this board:

        and i used ‘arduino as isp’ for programing that.(and i test pl2303 usb to serial adapter as programer too)
        when i want to see results, Arduino Serial Monitor window does not show anything
        for example:

        void setup() {
        void loop() {

        I have another question. Can I program the board through RX & TX pins.
        thank you.

        1. operating system: Windows 8.1 and windows 10
          Arduino IDE version 1.6.11
          I’ve used the following adapters:
          1- Arduino UNO (Arduino as ISP)
          2- PL2303 usb to serial Adapter
          3- FT232 usb to serial Adapter

          1. 🙂 Hm… this is not working in that way… You are close, but you have to expand your knowledge about serial/USART/RS232 link between a MCU and computer.

            So… I can’t answer in comment section because, I should respond to several comments that relate to each other … so I can’t imagine how to split my answer across these comments.

            So I have a better idea: I will write a new blog post where I will try to make a tutorial about these things, a tutorial to respond to all the issues I’ve seen in comments here (or elsewhere in this site, about serial, usart, bootloader…).

            I set to myself a deadline of 7 days from now to complete such a tutorial.
            So … stay tuned for next days

            1. ok.i am looking forward to your new blog posts
              thanks a lot. 🙂

            2. hello Silvius. do you complete this tutorial. Please notify me when done. thanks

              1. Not yet, not yet. I am working on it…
                I will definitely announce you. 🙂

                1. thanks a lot and best regards. 🙂


                It took longer than I thought. In fact is not a tutorial … It’s what I could not say in comments…
                You will see why … 🙂

                1. Thanks Silvius

      2. Hello . thank you for your attention.
        i made this board:

        and i used IDE 1.6.11 & ‘arduino as isp’ for programing that.(and i test pl2303 usb to serial adapter as programer too)
        when i want to see results, Arduino Serial Monitor window does not show anything
        for example:

        void setup() {
        void loop() {

        I have another question. Can I program the board through RX & TX pins.
        thank you.

        1. Hi Mirzapour,

          i want to do that to. iF u found the answe kindly please inform me.

          Very appreciated

    2. I want to do that too. If u found an answer please tell me…

      1. 🙂 Actually to me go smoothly …I used the USART from ATmega16 and ATmega32 (and 1284).

        I used my development board from here:
        and this rs232 module (DIY style):

        Right now I’m working on a project using the USART for RS485 interface and everything works well …

        but over time I have used other types of development boards with RS232/RS485/USB-to-Serial interface included…

        What I meant is that I can not answer the question “Why serial link between the MCU and computer not working?” … because it could be many causes, and and I know nothing about your hardware and software setup.

  6. Great information. Thank you. Struggled to use Atmel Studio 7 IDE. going to try this instead.

  7. i have compiled for ethernet project and it shows low data memory but atmega32 has 2kb RAM…so how to change the RAM size mentioned in the definitions.

    1. I have compiled some examples of Ethernet examples with Arduino 1.6.12 and Atmega32 and worked OK. for Using atmega32 with arduino 1.6.xx please read this article:

      I do not use 1.5.xx or older, and no longer have installed it.

  8. hello,
    I’m Sony from Indonesia, it’s first time using Arduino. Usually I use AVR Studio in assembler language.
    Now I have install Arduino 1.8.0 and I’m not found Tool -> Board -> ATMega32-External 16MHz. Also I’m not familiar using C. Where can I found the bootloader hex file that I download into ATMega32 completely with fuse setup? So I can use my ATMega32 with arduino software.

    1. Please follow tutorial here:
      After that select:

      Tools -> Board -> ATMega32-External 16MHz
      Tools -> Programmers -> USBASP

      You do not need a bootloader, you can use USBASP as programmer and this is all. Just plug USBASP to dev board, or your project.

  9. when I try to upload, I get theese errors. Please Help!

    Warning: Board arduino:avr:mega32-1 doesn’t define a ‘build.board’ preference. Auto-set to: AVR_MEGA32-1
    Warning: Board arduino:avr:mega32-8 doesn’t define a ‘build.board’ preference. Auto-set to: AVR_MEGA32-8
    Warning: Board arduino:avr:mega32-16 doesn’t define a ‘build.board’ preference. Auto-set to: AVR_MEGA32-16
    Sketch uses 838 bytes (2%) of program storage space. Maximum is 32000 bytes.
    Global variables use 9 bytes of dynamic memory.
    Error while uploading: missing ‘upload.tool’ configuration parameter

    1. I don’t know what version or Arduino IDE and OS version…
      If arduino IDE is > 1.6.xx please follow this:

      This solution is for 1.5.xx

  10. i am having error related to “A0” was not declared in the scope. in my code i declared it even though this error comes. here is my code. please suggest some help.


    LiquidCrystal lcd (5, 4, 3, 2, 1, 0);

    const int ldrPin = A0;

    void setup() {

    lcd.begin(16, 2);

    pinMode(ldrPin, INPUT);


    void loop() {

    int ldrStatus = analogRead(ldrPin);

    if (ldrStatus <=300) {

    lcd.setCursor (0, 0);
    lcd.print ("XX");


    else {

    lcd.setCursor (0, 1);
    lcd.print ("YY");



    1. Try analogRead(0) … analogRead(7)
      or you can use ldrPin = 0 … ldrPin = 7

  11. Hi Mirzapour,

    i want to do that to. iF u found the answe kindly please inform me.

    Very appreciated

Leave a Reply to harit Cancel reply

Your email address will not be published. Required fields are marked *

OpenHardware.Ro © 2017 Frontier Theme