Placing variables inside or outside of draw
in
Programming Questions
•
1 year ago
Here is another basic question about variables.
I know you have the option of defining then either inside of functions or outside. Outside means that they are available within all of the functions and inside means they only work inside that specific function. Also if they are defined in a specific command like a for loop, they only are accessible within that loop.
My question is why. Why would you not just make them all available all the time?
Is there a drwback such as reduced speed, memory consumption, etc or is it just an option for the purpose of organization??
I have been defining everything up front just to have a place where my whole variable list is placed but I don't know if I am hurting myself in the process... specially in arduino sketches where speed and memory are big issues.
1