Concept Flow - Volatile keyword and why it matters
Declare volatile variable
Compiler reads variable
Variable value may change anytime
Compiler must NOT optimize reads/writes
Program uses latest variable value
Correct behavior with hardware/interrupts
The volatile keyword tells the compiler a variable can change anytime outside program control, so it must always read/write it fresh.