Language: EN

programar-arduino-con-eclipse-2

Programming Arduino with Eclipse (2 of 2)

In the previous post we saw how to set up our computer to program Arduino with Eclipse, the popular multi-platform IDE, and enjoy all the power of the C language without the many limitations that the use of the Standard IDE imposes on us.

In this post, we will learn how to recover the Arduino libraries, and load programs directly onto our device. In this way, we will be able to program Arduino with Eclipse, maintaining the functionalities and convenience of the standard IDE, and adding all the development advantages of Eclipse.

Recover Arduino libraries

To recover our Arduino function libraries in Eclipse, we have three options

  • Compile the libraries directly from their source code.
  • Generate a program from the Arduino IDE, and copy the compiled temporary file (called a.out) to our project file.
  • Use an already generated project in which the libraries have been correctly configured.

Logically, the easiest option is the third one, using a properly configured project as a template. Fortunately, this is even easier thanks to the work of Rico Van Genugten, a developer who has taken the trouble to configure and share a template with the community in a git repository.

To download the template, we must go to the following address https://github.com/ricovangenugten/Arduino-Blink-Eclipse-Project or, if we are on a Linux system, simply type the following in a terminal to clone the repository to our hard drive.

sudo apt-get install git
git clone https://github.com/ricovangenugten/Arduino-Blink-Eclipse-Project

It is advisable to save the template and always work with a copy. This way we preserve the original as a backup in case the previous repository becomes unavailable.

Now we import the project into Eclipse. We select “Import” and, among all the options, we choose “Existing projects into Workspace” arduino-eclipse-01 In the next screen, we select the folder where we have the project template. We click on “Select All” and check the option “Copy projects into workspace” arduino-eclipse-02 We have now correctly imported and configured the Arduino function libraries.

Configure the loader

Now we are going to select the loader, in order to directly load the programs that we carry out on our Arduino with Eclipse. We select with the right button on project properties. In the AVR tab, we select AVRDude, and click the Edit button. arduino-eclipse-03 In the next screen, we must configure the loader for our device. We correctly configure the USB port to which our device is connected. Then, we choose the loader model:

  • Atmel stk500 v2 loader for Arduino Mega
  • Arduino loader for the rest of Arduino models

arduino-eclipse-04 As for the speed (baudrate) we must choose

  • 115200 for Arduino Mega
  • 19200 for Arduinos based on ATmega168
  • 57600 for Arduinos based on ATmega328p

We accept the changes made and the loader is now configured.

Configure the device

Finally, we must indicate to Eclipse and the AVR plugin the type of device we are working with. To do this, within project properties, we select the “Target Hardware” section. arduino-eclipse-05 We click the “Load from MCU” button and, if we have configured everything correctly, it should automatically select the type of Arduino we have connected and its speed. We verify the data, and if they do not appear or are incorrect, we modify them manually.

Final test

Finally, we need to verify the final setup and that we have made the configuration correctly. To verify that everything is working, with the template project loaded, we click on the button indicated in the image. arduino-eclipse-06 If everything has gone well, the program should be loaded onto our device, and the integrated LED will start flashing slowly. Congratulations! You can now program Arduino with Eclipse, with the same ease and functionalities of the Standard IDE, but adding all the power of the C language without limitations.

Download the code

All the code from this post is available for download on Github. github-full