I coded some functions for another sketch. I now want to use those functions in another project without having to include the whole code. Can't I use #INCLUDE? Im not clear in the syntax to use it or where the file should be saved.
Thanks its been many many years since I studied programing.
#INCLUDE <myCountDownsdkd.ino> // the file that hold the function countDown()
void setup() {
// put your setup code here, to run once:
}
Can't I use #INCLUDE? Im not clear in the syntax to use it or where the file should be saved.
It would have been faster to test the code than to write this post. Try it yourself.
If the other ino file is in the same directory as the one you want to include it in, there is nothing you need to do. The IDE combines all ino files into one cpp file for compiling.
If the other ino file lives somewhere else, you need to include the full path.
Of course, if the other ino file includes a setup() and loop() function, you can't do what you want.
after reading some more I think what I want to do is create a library and then include that in future sketches?
Sorry just getting my feet wet after a long time.
You can include a .h or a .cpp file, that would be clearer than the .ino.
A .cpp without objects (just functions) should also work as long as you have a separate header file with function prototypes so that the file ordering doesn't get in the way. Haven't tried this, but it should work.