1A variable is declared inside a case
Wrap the case body in curly brackets so the variable lives only there.
void setup() {
Serial.begin(9600);
int mode = 2;
switch (mode) {
case 1:
int level = 5;
Serial.println(level);
break;
case 2:
Serial.println("two");
break;
}
}
void loop() {
}void setup() {
Serial.begin(9600);
int mode = 2;
switch (mode) {
case 1: {
int level = 5;
Serial.println(level);
break;
}
case 2:
Serial.println("two");
break;
}
}
void loop() {
}Mokxi’s build tab says: A case above declares a variable, and the switch would jump past it