I think I might be going crazy. I have a switch statement which takes in a character. If I declare a variable AND set its value within the switch statement somewhere, any cases after that will never get called (including the default case). Am I missing something here? Note that the type (or name) of "var" does not seem to matter. Is anyone else experiencing the same thing I am?
void setup(){
Serial.begin(115200);
}
void loop(){
serialCheck();
}
void serialCheck(){
if(!Serial.available()){ return; }
char input = Serial.read();
switch(input){
case 'w':
Serial.println("what");
break;
case 't':
Serial.println("the");
break;
case 'h':
int var = 123; // this line somehow breaks everything
// int var; // but this is fine
Serial.println("heck");
break;
case 'i':
Serial.println("is");
break;
case 'g':
Serial.println("going");
break;
case 'o':
Serial.println("on?");
break;
default:
Serial.println("Invalid");
}
}