It seems like I should declare variables ahead of setup() and initialize them inside of setup().
QuoteIt seems like I should declare variables ahead of setup() and initialize them inside of setup().Keep in mind that more fundamentally where you declare a variable determines where that variable can be used, it's 'scope'. Declared before setup() makes it a 'global' variable able to be referenced anywhere in the sketch, inside setup(), loop(), and any user functions you might define. If you declare it in setup() then the variable is only available inside the setup() function.Generally making all variable declaration global is not considered a good programming practice as variables declaration should be limited to the function that uses them, and only if variables must be shared by multiple functions should they be declared global. That 'good practice' aside, I tend to think in a micro-controller environment when using small sketches that declaring variables global is not the sin that the experts would have you believe and that there is some flexibility from such ridged rules that one can deviate from. Lefty
sellonoidA reference to the page would be welcome.Best regardsJantje
Quote from: Jantje on Dec 29, 2012, 02:25 amsellonoidA reference to the page would be welcome.Best regardsJantjeJantje- This is the page: http://arduino.cc/en/Reference/SetupThanks to the other posters too for the info.
Use it to initialize variables, pin modes, start using libraries, etc.