When I move my variable "button" over into my_new_tab the compiler is logging:
error: 'button' was not declared in this scope
pinMode(button, INPUT);
Do I need to declare it as a blank variable in my_sketch first? The variable value (in my_new_tab) is required during setup (as it is informing which pin the button is connected to).
I'm looking to place my programmable variables in my_new_tab, with the static code running in the main sketch. Am I best having 2 ino files? What are the advantages of having a .h & a .cpp?
ino files a concatenated together by the Arduino sketch preprocessing. everything is global in ino files.
with h and cpp you can control the visibility/scope of variables and functions to other parts of the program. and h and cpp are the way if you plan to make a library.
Juraj:
ino files a concatenated together by the Arduino sketch preprocessing. everything is global in ino files.
with h and cpp you can control the visibility/scope of variables and functions to other parts of the program. and h and cpp are the way if you plan to make a library.
Ah... Gotcha. The h file being the central "hub" where you would place all global variables. Sounds like ino files will do the job for me today.
I see the main issue that I was experiencing now...
I was trying to declare integers for my pin mappings, before the setup function.
As I was putting these into the new tab, they weren't being declared before the setup function was called.
I've swapped this around now so all the initial constants & integers, etc are declared in the main_sketch, with the setup & loop functions then operating from my_new_tab.