Yes.
This is a part of the compiler that looks at your code and tries to improve it for speed or/and size.
And hence it might happen when it looks at a part of your code where you use count
multiple times it will optimize this part in a way where it only retrieves it once from memory and uses it over and over again, ignoring any change made by the interrupt. volatile
tells it to always retrieve the current value from mem.
Your blink will be unobservably fast the way you do it there.
If you do this, you'll get a LED toggle with each bubble
void bubbleCounting (void) {
count++;
digitalWriteFast(Led2, !pinReadFast(Led2)); // toggle led
}
Correct, hence the need to keep them short and fast so the upload won't even notice.
So also no need to mask the interrupts since it will return and carry on just where it left off before the interrupt.
But in order to avoid missing a count, you might want to do count = 0;
immediately after this line request.body = "{\"value\":" + String(count) + "}";