Working on a project for my son's school and running into some unusual behavior with variables. Please help (excuse the code, it is very messy and copied and pasted from different sources):
Variable "int functionstatus;" is defined on line 53 and then it is assigned value of 1 on line 125 (under void setup). Unfortunately, when running the code, the value ends up 0 (looking through serial monitor). Cannot figure out what causes it to reset to 0 or why it cannot recognize that value of 1 was assigned under void setup. Additional info:
----a) The code was working fine until recently, it just started doing this after making a minor change unrelated to this particular variable.
----b) All other variables defined and assigned before or within void setup work fine.
----c) the functionstatus variable holds the value fine once it is assigned through void loop. it just does not take an assignment from void setup. (again, this was working fine until recently).
P.S. This may be related, although little different issue: I had another issue with another board and code where I was using similar variable to control different phases of operation. At some point, based on serial monitor, variable values stopped making any sense but the board and connected electronics continued behaving normally. I figured that the serial monitor was reading the variable values incorrectly but the board (the the compiled code in it) could see the correct values. so, I left it alone. So, is it possible there is some problem with a compiler or serial monitor or software on my PC that may be causing problems?