How to use external files

I would not go to the trouble of creating a library if the code is only to be used in one project. The value of a library is when you want to use the same code in several projects.

A simple way to organize your code is to create additional .ino files in the same folder as your principal project .ino file. All of the .ino files will appear as tabs in the Arduino IDE and the IDE will combine them all into a single file before compiling your code.

You can alternatively put your code into .h and/or ,cpp files and use #include "myfile.h" to include the file if it is in the same folder as the principal .ino file.

"Proper" C/C++ programmers use the .h files to define things and the .cpp files to contain the code but, as far as I can see, the compiler is quite happy when I put all my code into a .h file (by which you will realize that I do not consider myself a proper C programmer :slight_smile: )

...R
Planning and Implementing a Program