// Variable scope shown on the Serial Monitor output. Local scope overrides global scope.
int a = 9600; // global "a1"
void setup() {
Serial.begin(a); // using the global variable value of "a1" = 9600
Serial.println(a); // global "a1" = 9600
int a = 2; // this new "a2" is locally defined in "setup()" while global "a1" is still 9600
for (int a = 7; a < 9; a++) { // this new "a3" is local only inside "for"
Serial.println(a); // this "a3" is local to this "for" loop
}
Serial.println(a); // this "a2" is from the definition inside "setup" with global "a1" still 9600
}
void loop() {
Serial.println(a); // this is the global "a1" as local variable "a2, a3" stay within their scope
while(1); // stay here
}