The Arduino hardware processing platform has become ubiquitous within the tech-loving community, and even non-techies will soon understand why it's so simple to use. Experienced programmers, however, can also benefit from this physical processing platform by taking advantage of ready-made code, but they might get frustrated by the overly simplified GUI that comes with Arduino software.
This tutorial will show you how to get full control of your Arduino by showing you how to take advantage of the C ++ code it offers you. You will learn how to use (or modify) this code to create your C ++ programs for Arduino platforms, using the Eclipse C ++ IDE, the AVR-GCC compiler and AVRdude to download your programs to the hardware.
Steps
Step 1. Download all necessary files and software
Between these:
-
The latest Arduino software package, which includes all the ready-made C ++ files that allow it to work, as well as the simple Java GUI dedicated to non-programmers. Once the other software is installed, this is the only file you will need from now on!
- AVR-GCC, which is the compiler for the AVR series of microcontrollers (heart of an Arduino). If you are a Windows user, get WinAVR.
- The Eclipse IDE for the C ++ language, where you will do the coding and upload the code to your Arduino! Eclipse requires that you have the Java Runtime Environment installed.
- The Eclipse AVR plugin, which provides the Eclipse IDE with the functionality it needs to communicate with your Arduino.
Step 2. Extract the files for the Eclipse IDE to a dedicated folder
After that, extract the files for the Eclipse AVR plugin to the same folder (or copy the contents to the folder).
Step 3. Create a C ++ project in Eclipse and use the following settings:
- Make the project "AVR Cross Destination Application" type.
- Make sure that the "Debug" option is UNCHECKED when selecting the Creation Configurations (and verify that the "Release" item is SELECTED).
-
When asked for hardware details, make sure you select the correct frequency (typically 16,000,000 Hz) and the right microcontroller, depending on the type of Arduino available.
Step 4. Extract the latest version of the Arduino software from its site
Copy the entire '\ hardware / arduino / cores / arduino' folder into that of your project. Now Eclipse is installed and the plugin is configured: from now on this is the only folder needed to start new Arduino projects from scratch!
Step 5. Create a main.h file with void setup (), int main () and void loop () declarations
Also include "WProgram.h" (with quotes) in this header; this connects it to all the Arduino code.
NOTE: Starting with Arduino 1.0, include "Arduino.h" instead of "WProgram.h".
Also, you must include the appropriate "pins_arduino.h" file from arduino-1.0.1 / hardware / arduino / variants. Arduino vers. 1 uses the "standard" variant.
These changes were made in the version of Arduino 1.0 released on 30.11.2011, according to the revisions.txt file that is installed with the IDE.
Step 6. Fix Arduino software compiler errors
Starting with Arduino version v0018, this will include the following changes:
- main.cpp: delete "#include" at the top and make sure your "main.h" is included instead.
- Tone.cpp: Change the last two & to have double quotes instead of angle brackets ("wiring.h" & "pins_arduino.h").
- Print.h: the function declaration "void function (int inputs) = 0;" must be changed to "void function (int inputs);" or, in other words, delete "= 0" so that it is not a pure virtual function.
Advice
- Be careful not to work in 'debug' configuration! It can cause further errors.
- To download the programs to the hardware, in your project settings you need to configure AVRdude to use the correct serial port at 57,600 baud and select the 'Arduino' configuration.
- Over time you will learn to work around the code - there are some errors that take a long time to find.