Is there a way to define a global variable within a function or nearby and just outside the function? By global variable I mean a variable that is accessible throughout the entire sketch.
I have written several functions that I can potentially use in new sketches. I would like to include these functions with all their global variables at the bottom of my sketches, rather than putting their associated variables say at the beginning of the new sketch and the majority of the function at the end of the sketch.
I tried putting these function global variables just above and outside the function but I get "not in scope" errors. It appears that global variables are best declared at the top of the sketch.
P.S. I think that I can make these functions into libraries and add them to my sketches via #include statements, but I'll reserve that idea for when I have more time to learn how to do it (I know that is supposed to be easy).