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