Click here to Skip to main content
15,795,398 members
Articles / Internet of Things / Arduino

Creating Arduino programs in Eclipse

Rate me:
Please Sign up or sign in to vote.
5.00/5 (9 votes)
23 Jun 2015CPOL12 min read 143.8K   9   81
Article on setting up Eclipse to build programs for Arduino Uno.


This article describes how to set up Eclipse IDE and AVR Eclipse plugin to be able to develop programs on a Windows computer for Arduino Uno. It should work also for other AVR-based Arduinos.

There are many articles on the Internet about developing programs for Arduino, but most of them are out of date, too complicated, based on Linux system and so on. This is quite natural considering the speed with which the tools are changing, so this article will sooner or later also become out of date. But for now (middle of 2015) it should work fine and I believe it is also "reasonably simple" (read as simple as I could make it).

This article is based on the Eclipse Luna SR2 with AVR Eclipse plugin and Arduino IDE 1.6.5-r2 (all tools in their latest versions as of June 22, 2015).


I probably don't need to tell you why use Eclipse instead of the Arduino IDE. If you plan to create more complex project with your Arduino or even see yourself as an embedded software developer some day, you will soon outgrow the Arduino IDE. And then there are two main options: Eclipse or Atmel Studio. If you read this, you probably decided for Eclipse, which is choice I like myself too.

Once you decided for Eclipse, there are two main roads you can choose:

The first road is easier, but I did not like it when I tried it some time ago. Personally, I consider it somewhere in between the real-world programming and the Arduino IDE. For example, the compiler options you can set are very limited. If you decided to use the real-world tools, why stop half way through? But the plugin is developing quickly, so maybe in the current version things have improved. But anyway, this article is about the second road, using AVR Eclipse plugin.


Install the tools

We will need the following tools:

Here are installation instructions:

From download the Arduino software.

Current version (June 2015) is 1.6.5-r2. You can either download installer or a zip file. In case of zip file just extract it to any folder on your computer, for example, to c:\programs\arduino1.6.5-r2.

From download the Eclipse IDE for C/C++ Developers;

Current version (June 2015) is Luna SR2. I recommend using 32-bit version even for 64-bit Windows, because I am not sure if everything would work with 64-bit Eclipse.

There is no installation needed. You download a .zip file, which you can extract into any folder on your computer, for example, to c:\programs\eclipse.
To start Eclipse IDE, go to the eclipse folder and run eclipse.exe.
You may want to create link on your desktop for quick access.

When Eclipse starts, you need to select location for your workspace. This is a folder on your computer where all your projects will be located. Later you can use several workspaces and change the default location, but for now I recommend just accepting the default offered by Eclipse and moving on.

AVR Eclipse plugin
Start the Eclipse IDE and in the main menu select Help > Install New Software.
In the Work with box enter this update site address:
and press Enter on the keyboard.

After a while the list below will display AVR Eclipse Plugin item. Select it by checking the box next to the plugin name and click the Next button below.
Follow the wizard to install the plugin. It takes quite a while. You will need to agree with license agreement and confirm installing of unsigned plugin. After the installation, accept the offer to restart Eclipse.

Tip: You can find tutorial with pictures on the AVR Eclipse plugin website at:

MinGW tools
The MinGW tools are needed to obtain the GNU make utility. If you have Atmel Studio 6.x installed on your computer, you can skip this step; you will find make.exe in the [Atmel Studio location]\shellUtils. We will need this path in AVR Eclipse plugin configuration as described in the next section.

To install MinGW:
From follow the Downloads link on the left.
This will take you to
Near the top of the page you will find "Looking for the latest version?" line and a link to download.
Download the mingw-get-setup.exe (direct link:

Run the setup program.  In the first screen leave all settings at defaults, change the Installation Directory if you prefer and click Continue.

Image 1

In the next step wait for the download of some files and click Continue.

You should see a MinGW Installation Manager window. In the list of available packages click on the box next to "msys base" (the last item in the list).

From the context menu select Mark for Installation.

Image 2

From the menu at the top of the window select Installation > Apply Changes.

Image 3

In the next step click Apply button.

Image 4

After a while the MinGW tools should be installed. Close the window. 

We are now ready to configure the AVR Eclipse plugin.


Set up the AVR Eclipse plugin

Start Eclipse and in the main menu select Window > Preferences.
In the Preferences window expand AVR > Paths.
Use the Edit... button on the right to set the paths as shown in the following picture.

Image 5

Here are the path on my computer:

AVR-GCC: C:\Programs\arduino-1.6.5-r2\hardware\tools\avr\bin
GNU make: C:\mingw_test\msys\1.0\bin
AVR Header Files: C:\Programs\arduino-1.6.5-r2\hardware\tools\avr\avr\include
AVRDude: C:\Programs\arduino-1.6.5-r2\hardware\tools\avr\bin

You can see that most of the paths point to the Arduino location. The GNU make tool (make.exe) path points to the MinGW location. The paths may be different on your system, depending on where you installed the tools.

To set the paths, use the Browse button in the window for path selection and select Path source: Custom; see the picture below.

Image 6

Next, select the AVRDude category on the left.

Check the box "Use custom configuration file for AVRDude".

In “AVRDude config file” box browse to the path of this file in your Arduino installation. Here is how it looks:

Image 7

The config file path is [your Arduino path]\hardware\tools\avr\etc\avrdude.conf.

Close the preferences window by clicking the OK button.<o:p>

Note: We will return to this window again in the next step, but it seems closing the Preferences window is required to apply the changes. Without this, the next step fails with error that AVRDude cannot find its configuration file.

Open again the Preferences from Window menu.

Select AVR > AVRDude.

Click the Add button on the right-side of the the Programmer configuration list.

In the window which opens, select Arduino from the “Programmer Hardware” list.
Enter some name in the Configuration name field above the list, for example, Arduino.
Enter the serial port to which your Arduino is connected into the "Override default port" box below the list.

Note that the port name must be written like this on Windows: "//./COM15".  (with your COM port number instead of 15, of course). See the picture below.

Image 8

Close the window with OK and then close the Preferences window also. The IDE is now ready for Arduino development.<o:p>


Create your first Arduino program

This section describes how to create project with Arduino MCU Framework (the software library), so that you can use the Arduino functions in your program.
First, we will create a path variable in Eclipse which will allow us to easily update our projects when new version of Arduino appears. This is only needed once in a workspace.

In Eclipse main menu select Window > Preferences.

In the Preferences window expand General > Workspace > Linked Resources.

Click the New button to add a new path variable.
Name it ArduinoPath and point it to the main folder of your Arduino installation, in my case c:\programs\arduino-1.6.5-r2. See the picture.

Image 9

Close the preferences window.

Now we are ready to create new project.

In Eclipse go to File menu > New > C++ Project.

Enter name of your project, for example, blink.
Select AVR Cross Target Application > Empty Project and click Next.

Image 10

In the next step leave everything as is and click Next.

In the next step select MCU Type: ATmega328P and MCU Frequency (Hz): 16000000. (that is 16 MHz).

Image 11

Click Finish.

We now have an empty project and will add links to the Arduino files into the project.

In the Project Explorer window in Eclipse right-click on the project and select New > Folder from the context menu.

Image 12

In the New Folder window expand the Advanced options in the lower part of the window and select the "Link to Alternate location (Linked folder)" option.

Then click the Variables... button and select our ArduinoPath variable from the list.

Then click Extend... button.

Image 13

In the Variable Extension window you should see the sub-folders of the Arduino folder.
Browse to hardware\arduino\avr\cores\arduino and click OK.

Image 14

Now you will be back in the New Folder window and the path to our linked folder should point to ArduinoPath/hardware/arduino/avr/cores/arduino; see the picture below.

Image 15

Click Finish to close the window.

Repeat the same procedure for another folder. The location of this folder will be:


Now you should see two (linked) sub-folders in your project: arduino and standard.

Image 16

Go to preferences for your project (Alt + Enter or right-click the project and select Properties).

Expand C/C++ Build > Settings category.

At the top of the window, in "Configuration" list select [All configurations].

Select the Additional Tools in Toolchain sub-category.

Check the box next to "Generate HEX file for Flash memory".
The HEX file is the output of the build process which is later uploaded to the microcontroller on your Arduino board.

Image 17

Now select the sub-category AVR C++ Compiler > Directories and add the two Arduino folders which we have added to our project into the list.
The easiest way is to copy-paste the following two paths, including the quotation marks (click the small Add button and then paste one path; repeat for the other):


Alternatively, click the Add button, then Workspace button in the Add directory path window. In the Folder selection window browse to [your_project]/arduino and click OK. Click OK again to close the Add directory path window. Repeat the same for the “standard” folder.

Image 18
This tells the compiler to search for source code in these locations.

Repeat the same step also for the directories of the C compiler in AVR C Compiler > Directories.

Still in the Preferences window, select AVR > AVRDude and in the "Programmer Configuration" list select Arduino. This is the programmer we have created earlier in the Set up the AVR Eclipse plugin section. If you do not see any item in the list please go back to that section and make sure you have done all the steps.

Image 19

Now we will add source file with our setup() and loop() functions.

Right-click the project and select New > Source File.
Enter some name for the file with .cpp extension and click Finish. The name could be the same as the project’s name or sketch.cpp etc.

Image 20

Click Finish to create the file. It will appear under the project in Project Explorer. Double-click it to open it.

Paste the following code into the new file:

#include "arduino.h"

void setup(void)
    pinMode(13, OUTPUT);

void loop(void)
    digitalWrite(13, HIGH);
    digitalWrite(13, LOW);

Save the file.

Note: In default configuration Eclipse does not save the files before build. I recommend enabling auto-save in Window > Preferences > General > Workspace:  "Save automatically before build”. Without this you will often forget to save the changes after modifying your code and will be actually building the old version, without these changes.

Build your project.

The project should built without errors, there will be some warnings about delay functions which have no effect on our program. The build may take little longer first time because all the Arduino core functions are built, but later, the compiler is smart enough to build only changed files, so it takes only few seconds to build the program.

Now upload your project to your Arduino board.

First, connect the Arduino board to your computer. Give the computer enough time recognize the board.

Now click the AVR icon in Eclipse toolbar.

Image 21

Your program will be uploaded to the board. Check the results in the Console window in lower part of Eclipse. There will be some messages from AVRDude. It should end with "avrdude done. Thank you."

Image 22

You should now see that the LED on your Arduino is blinking. This means our program is running.

If you get an error message "port is blocked" you probably have wrong COM port number in the AVR Eclipse plugin configuration. To fix this go to Window > Preferences > AVR > AVRDude. In the "Programmer configurations" list select your Arduino item and click Edit. Make sure the number of COM port (for example, //./COM15) is correct. You can find this number either in the Arduino IDE or in Hardware Manager of your computer.

You are now ready to develop your programs in Eclipse. Don't miss some of the cool features of a professional IDE, for example, you can look at the source code of the Arduino functions: just select the function name, right-click and select Open Declaration.

Image 23

Points of Interest

In most tutorials I have seen the Arduino core functions are pre-build into a static library first and then this library is added to your project(s). In this tutorial we link the Arduino files directly to the project and build them together with our code. In my opinion this is easier to set up, easier to update and the build does not take unbearably long, so I consider this a better option than using static library.

If you update to a new version of Arduino software, you just need to change the value for the ArduinoPath variable and all the projects should work with the new version.



2015-06-23 First version.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Employed (other) Tomas Bata University in Zlin
Czech Republic Czech Republic
Works at Tomas Bata University in Zlin, Czech Republic. Teaches embedded systems programming. Interested in programming in general and especially in programming microcontrollers.

Comments and Discussions

Questionfreertos led blink on arduino using eclipse Pin
Member 1577337813-Oct-22 10:06
Member 1577337813-Oct-22 10:06 
BugUploading failed - programmer is not responding Pin
Member 1491035412-Nov-20 17:40
Member 1491035412-Nov-20 17:40 
QuestionThe .hex is created and loaded, but it is not running (Mega2560) Pin
Member 1474840620-Feb-20 7:26
Member 1474840620-Feb-20 7:26 
AnswerRe: The .hex is created and loaded, but it is not running (Mega2560) Pin
Member 1474840621-Feb-20 2:05
Member 1474840621-Feb-20 2:05 
QuestionNEW --> C++ project (no longer available) Pin
Michael C Li16-May-19 8:35
Michael C Li16-May-19 8:35 
PraiseJan "AWESOME" Dolinay Pin
Member 123470782-Jan-19 3:08
Member 123470782-Jan-19 3:08 
GeneralRe: Jan "AWESOME" Dolinay Pin
Jan Dolinay22-Jan-19 22:37
professionalJan Dolinay22-Jan-19 22:37 
Thank you! I am glad it helped.
GeneralRe: Jan "AWESOME" Dolinay Pin
Michael C Li16-May-19 7:52
Michael C Li16-May-19 7:52 
GeneralRe: Jan "AWESOME" Dolinay Pin
Michael C Li16-May-19 8:30
Michael C Li16-May-19 8:30 
Questionserial monitor view Pin
Member 138622177-Jun-18 21:54
Member 138622177-Jun-18 21:54 
Questionso many errors Pin
Member 138622176-Jun-18 20:42
Member 138622176-Jun-18 20:42 
QuestionAVR > AVRDude in project properties Pin
Alf_Munich25-Feb-18 6:27
Alf_Munich25-Feb-18 6:27 
AnswerRe: AVR > AVRDude in project properties Pin
mmikkone31-Mar-18 23:16
mmikkone31-Mar-18 23:16 
AnswerRe: AVR > AVRDude in project properties Pin
Member 138623496-Jun-18 21:53
Member 138623496-Jun-18 21:53 
GeneralRe: AVR > AVRDude in project properties Pin
Seyfallah Raach20-Jun-18 2:22
Seyfallah Raach20-Jun-18 2:22 
GeneralRe: AVR > AVRDude in project properties Pin
Michael C Li16-May-19 7:54
Michael C Li16-May-19 7:54 
GeneralRe: AVR > AVRDude in project properties Pin
Michael C Li16-May-19 8:29
Michael C Li16-May-19 8:29 
QuestionArduino programs in eclipse over ubuntu Pin
Rahul Tiwari14-Aug-17 13:41
Rahul Tiwari14-Aug-17 13:41 
AnswerRe: Arduino programs in eclipse over ubuntu Pin
Jan Dolinay17-Aug-17 23:44
professionalJan Dolinay17-Aug-17 23:44 
QuestionIncluding an arduino library (undefined reference to) Pin
Member 1319218320-May-17 3:08
Member 1319218320-May-17 3:08 
AnswerRe: Including an arduino library (undefined reference to) Pin
Jan Dolinay22-May-17 1:12
professionalJan Dolinay22-May-17 1:12 
QuestionError *** unterminated variable reference. Stop. Pin
Member 1319218310-May-17 9:09
Member 1319218310-May-17 9:09 
AnswerRe: Error *** unterminated variable reference. Stop. Pin
Jan Dolinay10-May-17 22:01
professionalJan Dolinay10-May-17 22:01 
GeneralRe: Error *** unterminated variable reference. Stop. Pin
Member 1319218312-May-17 23:45
Member 1319218312-May-17 23:45 
GeneralRe: Error *** unterminated variable reference. Stop. Pin
Jan Dolinay15-May-17 3:25
professionalJan Dolinay15-May-17 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.