When I assign a global var to a certain value inside an if-block it has been changed to another value in the next statement. Somehow the address of the var is overwritten by some other process. It also does not stop at 1 value, this happens to the next vars that are assigned another value too. The vars are not defined in a row but should be close. I already installed a newer version of Arduino IDE, no change. Example:
menuActive=1;
Serial.print(menuActive);
gives results in the range 40 to 57 as far as I have seen till now. Further actions assign always the SAME value to next vars I assign after this. Anyone some idea what could cause this? Am I low on memory for local vars? This is compile message:
Sketch uses 21790 bytes (70%) of program storage space. Maximum is 30720 bytes.
Global variables use 1454 bytes (70%) of dynamic memory, leaving 594 bytes for local variables. Maximum is 2048 bytes.
edit:
As I already said, it is 21k of code. But I show you the part of the code that mishaves:
while ((digitalRead(rotSwPin) == 0) && lpress <= 200) {
delay(10);
lpress++;
if (lpress > 200) {
menuActive++;
menuLvl=0;
menuPos=0;
subPos=0;
}
}
Normally I use menuActive=1. Within the braces, it is still 1, out of that it changes. Maybe change from byte to bool.