How to compile and program Arduino Nano using an USBtinyISP programmer

This article is about how to program an Arduino Nano board using a cheap programmer USBtinyISP. First of all, I bought this programmer on Amazon Japan for just 440 Yen, shipping cost included. It arrived from China in about 1 week. The programmer had a 10 pin connector included, in order to connect it to the Arduino Nano board ISP connector. It looks like this. The USB cable was not included, but I already had one. I also bought the Arduino Nano on Amazon Japan, for just 480 Yen (it was a fake model from China).


The first step is to create a simple program to be flashed on the Arduino Nano board, which has an Atmel ATmega328 microcontroller. The board can be programmed also using the Arduino IDE, since the microcontroller has a boot-loader software preinstalled on it. However, since I wanted to flash a HEX file created with Atmel Studio, I had to use a programmer. The simple program which I created has few lines of code, and continuously toggles Arduino LED 13 (which is microcontroller pin Port B5) ON/OFF. Since my purpose was also to understand how C language code is converted into Assembly code, in case of function calls, I created a function which waits for 100ms. This makes the code a little bit more complicated of what it could be.

program_atmel_studioDDRB register is set to 255 (hex: 0xFF) in order to set all pins of port B as outputs. Then, inside the while cycle, pin B5 is continuously turned ON and OFF, by setting PORTB to 0x20 (1<<5) and 0.

memoryThe program is compiled by clicking on Build -> Build Solution. As you can see from the screenshot, the size of the program is very small (only 218 bytes). The binary file needs to be transferred on the microcontroller ROM memory, using the programmer. This job can be done by avrdude (this is the name of the programmer software). It is included in the WinAVR package, which can be downloaded here.


In order to program the Arduino Nano microcontroller, the programmer must be connected to the 6-pin connector on the Arduino board (ISP connector). Then, open the command prompt, and type the following commands. For more info, have a look at this detailed guide.

avrdude -c usbtiny -p m328p -U flash:w:Nano_HelloWorld.hex

In case everything was fine, you should see something like the screenshot below. Your program is now on the Arduino microcontroller flash memory, and it is running.

avrdudeJust some details about the command:

  • "-c usbtiny" tells to the programming software that the programmer type is USBtinyISP.
  • "-p m328p" means that the microcontroller is an Atmel ATmega 328p. The last part of the command,
  • "-U flash:w:Nano_HelloWorld.hex", shows that the HEX file (Intel HEX format) is called "Nano_HelloWorld.hex", that it must be written ("w") on the flash memory of the microcontroller.

The source code (Atmel Studio project) is available here: nano_helloworld. Below, a video shows how the board behaves after programming. The LED turns ON for 500ms (5 cycles x 100ms delay) and OFF for 2500ms (25 cycles x 100ms).

Author: Davide Cavaliere

I am an Italian Electrical Engineer graduated at Politecnico di Milano. My interests are motorcycles and cars, electronics, programming, Internet of Things, and Japanese culture.

2 thoughts on “How to compile and program Arduino Nano using an USBtinyISP programmer”

  1. Hello i got some quest's.
    You using Linux?
    I search how to compile and load Arduino scetches with the Arduino IDE not using the aduino Bootloader.
    Means mine programms are directley going to run after power up the Arduino Nano.

Leave a Reply

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