- Variables, Scope, You have to understand scope before reading about passing variables in Functions.
A variable declared inside the Function loop can only be accessed from inside loop. If you declare a variable inside setup, it can only be used there as well. Variables that are declared before the Setup function are global and can be used anywhere. Here is another page on this if needed. http://arduino.cc/en/Reference/scope
- How do I work with functions (Katz) A demonstration program
- Arduino Reference on Functions
- A discussion of ways to pass information to and from functions but it does not discuss the swap function that is also useful if you want a single function to modify a variable but do it from different parts of a program.