Suggestion for editing setup() entry in Language Reference

Checking the forum I noticed another newbie got confused in the description of setup() in the Language Reference page:

It states: "Use it to initialize variables,..."
Then in the example below a variable is initiated before setup().

I would suggest to avoid confusion that the above excerpt be changed to "Use it to initialize local variables,..."

LesB

I agree that the documentation is miss worded, Initialize is the wrong word.

Its more useful to setup/assign global variables. After a function returns, its local variables no longer exist. Sometimes people create libraries which use Arduino core functionality like PWM, Serial or millis().

When creating a global variable, their constructors are run before setup. So if it uses things like I mentioned above, the code using them must be setup/run after the internal init() function has run, which setup() is perfect for.

You'll notice many people make classes will init() or begin() functions which are usually for this purpose.