Arduino software

From Elcano Project Wiki
Revision as of 02:41, 10 October 2019 by Ptressel (talk | contribs) (Arduino software structure)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Development tools

In Arduino terminology, a program that runs on an Arduino is called a sketch. These are written in a limited version of C++, described here: . In addition, one can include libraries, which are written in C++. If there is code that would be useful to share between sketches, it can be put in a library. Many open-source libraries are available for Arduino -- this lists some popular ones:

There are several IDEs that support Arduino development:

It's recommended to start with the Arduino IDE as it's simpler and most Arduino information online assumes you are using it.

Arduino software structure

Arduino software has some quirks. Each sketch must be in a directory with the same name as the sketch filename. (That is, if the sketch is called XYZ.ino, then it must be in a directory called XYZ.) Libraries likewise need to be in directories, but names of files in the library don't need to match the directory name. One should avoid nesting directories -- if there are variants of some project (also something to avoid), it is better to put each in a directory at the same level. Also avoid putting extraneous .ino files in sketch directories. The Arduino IDE seems to compile whatever .ino files it finds, even if it's not the actual sketch, so other .ino files may be confusing if they have compile errors.

We have some local software conventions, mainly due to the fact that some settings and code need to be shared between different projects that run on different Arduinos, or are used on different vehicles with different structures.


This file contains information that is different per vehicle. This includes mechanical information (e.g. wheel diameter, turning radius, etc.) and electrical information (e.g. pin assignments). It is required by most projects. All the rest of the code should be written to be portable across a wide variety of vehicles.

A template version of this file, called SettingsTemplate.h, is packaged as a library, and is available in the General repository. SettingsTemplate.h should be copied to Settings.h, and local changes made in Settings.h as needed. Anything of general use can be put back into SettingsTemplate.h. Note this division between a template version of settings and a personalized version is the same division as is found with most application preferences or configuration files.


In the past, locally-written Arduino libraries were put in a libraries directory alongside one's sketch directories. But a change to the Arduino IDE caused this not to work any longer. They now want libraries put in the installation directory of the Arduino IDE, or just put in the same directory as the sketch.

Neither option is appropriate for software that has to be installed by non-administrators, or that is shared among projects. We are currently reconfiguring our libraries to deal with this. What we hope to do is go back to a local libraries directory, and have a separate repository for each locally-written library. We can use Git "submodules" to bring in the necessary libraries. Git supports soft links, so we can add links from each sketch to the libraries directory. This will allow using the original library structure.

This change is in progress. In the meantime, locally-written library directories, or libraries that are not available in the Arduino installation, can be moved by hand into the user's own libraries directory, and a link called "libraries" created in each sketch directory, that points to the libraries directory. The include statements should then have the form:

   #include "libraries/SomeLibrary/SomeLibrary.h"