Sharing definitions between programmes

I have been working on a project that has a set of fixed information shared between 2 Arduinos (one nano and one mega). This are essentially headers for information that is coming afterwards.
I would like to be able to update one list in a single file and then just upload into each arduino whenever there is a change.
I would think that using an include file would be the thing I needed but can't seem to find much info on how to use them, and even less for using them across multiple programmes.

or is going to be easiest to do as I have up to this point, but the windows next to one another, copy and paste/direct visual comparison. Both programmes will have to be re-uploaded when there are changes made to this list of definitions anyway.


The easiest way to share a header file over multiple sketches is to put it in a library.


sketch1.ino and sketch2.ino can then both contain:

#include <HeaderName.h>

They will both be using HeaderName.h from Arduino/libraries/HeaderName

You can use #include "full/path/name/to/file.h" if you want to refer to a shared file. IMHO that's a lot simpler than creating a library just for the purpose of sharing a file.

The fact that the Arduino IDE cannot use relative references for file locations is a real PITA when you get past the basics of Arduino programming.

I use the Geany editor for all my programming.

I have written a simple Python program to compile and upload Arduino code using the command-line IDE. I have a menu option in Geany to call the Python program. The Python program can also be used without Geany.

The Python program converts relative references to absolute references before passing the code to the Arduino IDE.


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.