I'm sorry for the basic question, but I have a switch case where any code placed after a certain function call simply never gets called, and I've spent half a day looking at it, so thank you so much for your help.
Running on an Arduino UNO.
Here is the loop, and every option in the switch case after the call to moist_sensor.read() simply never gets in:
void loop() {
while (Serial.available() > 0) {
char val = (char)Serial.read(); // read data byte by byte and store it
Serial.println(val);
switch(val) {
case 'O':
digitalWrite(13, LOW);
break;
case 'I':
digitalWrite(13, HIGH);
break;
case 'W':
water(2000);
break;
case 'E':
int reading = moist_sensor.readd(); //THE PROBLEMATIC LINE
//Serial.println(reading); // send the received data back to raspberry pi
break;
//it never enters any of these cases below
case 'M':
//String reading2 = moist_sensor.packaged_reading();
//Serial.println(reading2); // send the received data back to raspberry pi
break;
case 'W':
water(5000);
break;
default:
delay(5000);
}
}
I've tried changing the name of the function with fears of special keywords, swapping it with other cases (such as putting case 'W' above, where it works, and vice versa), and I always get the same behaviour. If i comment the line, everything works as expected.
I know the method isn't actually called all the time, but for sanity's sake, moist_sensor.readd() right now is just:
int readd() {
return 0;
}
It also works fine if its the last case, but this buggs me, and I want to create other cases with function calls.
Thank you so much!