while(!Serial.available()) vs while(Serial.avai...

I'm new to the Arduino and Processing, learning as I work on each project. I'm developing a SD card serial data logger, so I am trying and using various C serial communication functions. In forum messages I have seen "!" used in this way- while(!Serial.available()) My question is, how is this syntax different than the common use while(Serial.available())? I've searched and can't find this use explained... Please help with a link or explanation to this use

thanks, -Ken

The ! operator can be translated to the word 'not'

Have a look at boolean operators

As in "!=" that makes total sense. AlphaBeta, Thank you for this instant answer and the link to the Boolean Operator page. -Ken [smiley=dankk2.gif]

This kind of syntax is commonly used to check flags, slightly different although.

while(!SomeFlag);

This means it will stay on that line until the "SomeFlag" turn into 1 (or "high"). How? Well, while is a loop, and execution will keep into it while the condition is true. Remembering that 0 = false and 1 = true. In that case:

while(!Serial.available())                      while(!Serial.available());
{                               =        

}

If the return of serial function is 0, it will just wait doing loops of nothing. When Serial.available() turn into 1, the condition will no longer be true, as the opposite (!) of 1 is 0 and vice-versa, so it will get out of the while loop.