Hi,
I am working on a project which has 2 Arduino's talking to one another using SPI.
There is a lot of shared code between the two, and I have broken that out into separate .cpp/.h files, and am not ready yet to turn the shared code into libraries as it is still in a state of flux.
I was hoping to have 2 .ino files and all the .cpp/.h files in the same folder, and load each .ino into a separate instance of the Arduino IDE and run them in parallel, but this doesn't work as it tries to compile both .ino for the build.
The only way I have got it to work is to put the code into separate folders and anytime I make a change to the shared files, copy them into the other folder, not good at all...
The problem is that the folder is the sketch, not the .ino file. Because many Arduino sketches only consist of a single .ino file, the .ino file is often thought of as the sketch.
The only solution I can think of is to use the preprocessor to switch between the two programs:
#define CLIENT //comment this out before compiling for server
#if defined(CLIENT)
// client-specific code here
#else // defined(CLIENT)
// server-specific code here
#endif // defined(CLIENT)
Since all the .ino files of the sketch are concatenated into a single file before compilation, you only need to be sure that #define CLIENT macro will be defined above the code that relies on it, regardless of which .ino file that code is in.