Arduino: keep your project and sub-libraries under the same folder

From Tronche's wiki
Jump to: navigation, search

Your building a quite complex project for your arduino (or may be Teensy), so you gonna split your source code in multiple files, say for example you have a "sensor" module and a "communication" module, and the main file of your project is some glue between the different modules.

A first possibility is to write several .ino files, but the point is that he Arduino IDE machinery actually catenates your files before feeding them to the compiler, so you can't have static or local variables in your modules.

A second possibility is to have one .h and one .cpp file for each module using multiple tabs in the Arduino IDE. The problem is that you may have more tabs than you would like (twice as much as with method #1 above). Furthermore, you're stuck with the editor part of the Arduino IDE, which may or may not fit your needs (may not as your project grows bigger).

So you've split your project in multiple libraries, such as sensor.h + sensor.cpp, modem.h + modem.cpp, that kind of stuff.

Personal tools