Is it possible to put configuration options for an Arduino sketch in a separate file, which could be excluded from the code repository?
For example, I have a 'secret' key which the Arduino uses to interface with a web service - I'd like that to be out of the main code, and only included at compile time. Then I could put the source in a public repository without worrying about revealing that key.
I'm having a bit of trouble implementing this. I have a file in the same directory as my PDE file, called configuration.h, which contains the following:
#include "configuration.h" on the 3rd line of my PDE file.
When I compile, I get the following error:
"In function 'void setup()':" (that's all)
If I copy those configuration lines into the main code and remove the include statement it compiles correctly. I've tried it with #include <configuration.h> (note the angle brackets instead of quotes), but this fails to find the file.
Its usually frowned on to declare variables in an include file, one reason for this is to prevent the kind of problems you are finding.
Your declarations reference variable types that are defined in other header files and these my be include after you header. Because of the Arduino build process it can be difficult to control the order of includes.
You can work around your problem in a number of ways. One is to only use #defines and have the actual declarations in the source. This was what I suggested above but it gets awkward when you have arrays
Another solution is to use types are that are predefined. 'byte' is an arduino defined type, try your code with a native type like this: