Easy-to-use Atmel Studio project for Arduino + programming the Arduino from Python

Posted on Sep 29, 2012 in Arduino, C++, Electronics, Programming | 3 comments

In this article you will find an example project for Atmel Studio that you can use with Arduino. I have also included two Python files to easily upload the code to your board.


Arduino, pro’s and con’s

There are many reasons to like the Arduino, to name a few:

  • Many libraries available and lots of example code on the web.
  • Uploading code to your board with one click
  • Portability of libraries
  • Integrated serial monitor

But there are also many things that drive seasoned programmers away from the Arduino environment:

  • The IDE has about as many features as Windows Notepad.
    • No auto-completion or any other assistance that modern IDE’s offer to let you program faster
    • No debugging
    • Very unhelpful error messages
    • No ability to jump to the line of the error
  • Although all Arduino files are open source, it’s almost impossible to jump into a file to see for example what digitalWrite() actually does. The Arduino documentation is very basic and doesn’t even link to the source files.

Basically Arduino is a collection of great libraries with a shitty IDE. So this article will tell you how to ditch the shitty IDE and still use the libraries.

Enter Atmel Studio

Atmel Studio, especially since version 6, is an awesome IDE. It has the Visual Studio 2010 shell, which is a joy to use. If you try it once, you will never move back to the Arduino IDE.

The reason I moved to Atmel Studio in the first place is that I wanted to use in-circuit-debugging: setting breakpoints on the device. Say you are debugging a rotary encoder that uses interrupts. The only thing the Arduino environment offers you is to write something to the serial port. With in-circuit-debugging, you can set a breakpoint in the interrupt, turn the encoder, and get the following information:

  • You can see the value of all your variables.
  • You can see all your registers: are the interrupts configured correctly? What triggered the interrupt?
  • You can step through your code line by line to see where it takes a wrong turn.

If you want to use in-circuit-debugging, you will need a debugger like the AVR Dragon. I also recommend to get the Arduino Leonardo, which has JTAG. It’s a lot faster than debugWire, which is the only option for all other Arduino’s.

My example project

The guides I have found on using Arduino’s with Atmel Studio all involve many steps and usually require manual editing of a makefile. I wanted to make things simpler and wanted to be able to use the toolchain settings in Atmel Studio. I am also using the avr-gcc toolchain that comes with Atmel Studio instead of the Arduino toolchain.

My example project is hosted on GitHub. You can download it with the ‘Clone in Windows’ button, or the ‘ZIP’ button.

I used the non-blocking example from my ShiftPWM library. If you don’t have the ShiftPWM library on your computer, you can get it here. Git it a try, it can give you up to 768 PWM outputs on one Arduino.

To get the project to compile on your computer, you only have to take the following steps:

  1. Open the solution file
  2. In the project properties –> AVR/GNU C++ Compiler –> Directories, change the 3 directories to your point to your local Arduino directory. Also add the path for any other libraries you are using
  3. If you are not using a 16MHz Arduino, change F_CPU under AVR/GNU C++ Compiler –> Symbols
  4. In ArduinoFunctions.cpp, uncomment/include any .cpp files that you are using from the Arduino directories.

That’s it.

Programming your Arduino with Python

One of the benefits of the Arduino environment is that you can compile and upload your program to your Arduino with one button click. If you are compiling your code Atmel Studio, you will have to use avrdude from the command line. This can be complicated.

To make it a easier for you, I have include two Python files. You only have to edit a few lines in this file to have one click uploading without the Arduino IDE. Well, two button presses: F7 to compile in Atmel Studio. And F7 again in Python/Sublime text to upload your code.

The Python script will automatically get the right settings for your Arduino from boards.txt, reset your Arduino and upload a hex file with avrdude.

And what about the serial monitor?

Allright, the one thing we will still use from the Arduino IDE is the serial window. You don’t have to have any files open, just click the serial monitor button to use Arduino’s serial window.

So there you have it, the best of both worlds: awesome libraries AND an awesome IDE.


  1. Atmel Studio has a better serial monitor, Terminal Monitor. From Studio, Tools -> Extension Manager

  2. Nice write up. And for the serial monitor, there is an extension called terminal window for Atmel Studio 6.0. Just download and install. Then you can access the serial monitor inside atmel studio.

  3. Hi Elco –
    Thanks for sharing this. I had been trying to adopt this approach and I was very pleased to be able to use your work. I made a few changes to adapt it to how I prefer to work. These are written up at http://www.hilltop-cottage.info/blogs/adam/?p=211 .

    I hope this is OK and that I have complied with the GPL, attributed you correctly… Let me know if not.

    Cheers, Adam


  1. Adam @ Hilltop Cottage › Using Atmel Studio 6 IDE with Arduino (Uno and Leonardo) - [...] boards with different processors. The best I found, which is not at all “involved”, was by Elco Jacobs. He…
  2. How to: Step by step guide to setting up Atmel Studio (AVR Studio 6) for Arduino | aSensar - [...] suite our need. AVR Studio will can fill the gap for professional development tool. There are many pros and…

Leave a Reply

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