In C code on Arduino Nano, how can I refer to a global variable with the same name as local one?
Example:
int speed = 0;
void setSpeed(int speed) {
speed = speed; // set global variable to local one's value
}
Rename the parameter.
If you want the parameter to appear to be named speed
in a header file, you can still declare the function as void setSpeed(int speed);
. Only the definition needs to use a different name.