Where best to place user customizations?


I have an Arduino program that I'm distributing to users but it needs customization by the end user. e.g. Different users may have their circuits wired differently. So before setup() I have a sequence of variables which users can alter. e.g.

int numberOfChannels=1; //Edit this for the number of channels in your system
int myPin=2; //Edit this for your circuit
//more stuff follows


 //some stuff

Over time, however, the customization section has become very large. This makes it unwieldy. Consequently, I want to move the the customizations from the main .INO file and into a separate file. Another reason for doing this is that it will make version control easier. What would be the recommended way of doing this, please? I know I can have separate .INO files, but I can't move my global variables into this, because the auxiliary .INOs are tagged on to the end of the main one. I tried making a settings.h and settings.cpp pair, but the compiler seems to expect the code in the .cpp to be embedded in a class (I kept getting compiler errors about a missing constructor).


Use the TAB button in the IDE. (arrow over on the right) For large programs I use several tabs. First is the stored file name, capture notes, directions there. Then a_presetup: #includes for libraries, variable declarations, pin assignments b_setup: pinModes, etc. c_loop: start of loop d_moreLoop: if needed to break loop up e_endLoop

d, e break things up if needed. c_loop might just be: void loop(){ e_endLoop might just be: } // end loop bracket

then the stuff in d_moreLoop can compile and not have to worry about mismatched { }

The alphabetic names seem to make it compile in that order. Keep in mind this is a hardware guy playing the IDE for all it's worth 8)

Ah, I see... So the trick is to have nothing in the main .INO but comments. Then the rest of the functions are processed in alphabetical order. Thanks, that'll work for me for now. There must be a "right" way to do this, though...

Might be. That way works for me.
You can have stuff in the first one, but it has to be the stuff in pre_setup that would start a sketch normally.
I find it works good for notes, test status, thoughts on things to be fixed, or tested, or revised based on last testing, etc.

Yep, it does indeed work.