Sketch Organization: Includes

One issue I am having is findng a good method organization, as a long time .php programmer I have a burned-in-habbit of seperating my functions & classes then including them seperately, but with arduinio i'm finding myself tracing through inline code over and over & its not as productive

I know arduino does have an "include" fuction but I have never attempted to use it in the php sense, where its very effective it doesnt seem to popular with arduino outside of libraries & fonts.

  • Can I use include in that way with arduino?
  • Does arduino support conditional includes or functions like include_once?

Thanks in advance

as a long time .php programmer I have a burned-in-habbit of seperating my functions & classes then including them seperately

I do the same thing, but I'm a C++ programmer.

I know arduino does have an "include" fuction

No, it doesn't. It is programmed in C++. The compiler comes with a preprocessor that has #include as one of the directives that it understands.

but I have never attempted to use it in the php sense

It works exactly the same way.

  • Can I use include in that way with arduino?

Yes.

  • Does arduino support conditional includes or functions like include_once?

Those are preprocessor directives that are not specific to Arduino, so, yes. Although include_once is not a supported directive. Google "include guards" to see how that is done in C/C++.

Hi,

Couple of thoughts on Organization:

HERE is the template I start with.

HERE is an example with the model that embedded systems are usually:

  • READ SENSORS
  • MAKE DECISIONS
  • TAKE ACTIONS

And then, look at TABs in the Arduino iDE.. This is basically an "Include" system. I use it on larger projects like Home Automation and have tabs for all the I/O definitions, etc. The example I have is too big to put here, but I can put it up on the web if people are interested..

What Arduino Does: https://www.arduino.cc/en/Hacking/BuildProcess

A how-to by Luidr HERE

Looks like this:

Any other pointers, suggestions welcome!