Hi, I'm trying to change the value of a global variable from within the timer's ISR, and for the life of me I can't get it to stick.
The variable is declared: volatile int var;
Then in setup() I initialize it to 0: var = 0;
and in the ISR I increment it: var++;
It will increment it in the ISR, but it really seems like it's incrementing a local copy of the variable, because as soon as it returns from the timer's handler, the value returns to zero, so incrementing it this way simply makes it toggle between 0 and 1. If I increment it in the loop() function, the changes stay, but just not in the handler. Does anyone know why this is happening? Thanks!