Declare a volatile flag set by an ISR, polled by main.
Variables shared between an Interrupt Service Routine and main code MUST be `volatile` or the compiler may optimise the polling loop away.
Declare `volatile int data_ready = 0;` at file scope, then write a `while (!data_ready) { }` busy-wait in main.Sign in to save your code and track progress across devices.