SOLVED:Checking variable for while loop, updated from Interrupt

I am using a TIMER1 overflow interrupt, I have written a quick code to test to see if i can update a variable with the interrupt as its being checked by a while statement.

    #include "TimerOne.h"
    byte FLAG = 0;
    void setup()
      pinMode(6, OUTPUT);
    void callback()
      digitalWrite(6, HIGH);
      digitalWrite(6, LOW);
      FLAG = 1;
    void loop()
      Serial.println("SEND MESSAGE");
      while(FLAG == 0);
      FLAG = 0;

It doesn't notice the interrupt change in the FLAG status with : while(FLAG == 0);

It does notice the flag change however if i put something in the while loop to check eg:

while(FLAG ==0){ Serial.println(FLAG, DEC); }

Does anyone know why this is happening? Doesn't " while(FLAG == 0);" continuously check the state of FLAG anyways?

Any variable that's shared between interrupt code and the main code must be declared 'volatile':

volatile byte FLAG = 0;

In an interrupt handler? I don't think so!

thanks the volatile byte worked.

yes i know putting a delay in there is bad, in my actual program there is nothing like that.

thanks again