improving my while statement

This is what I normally do:

while(1) {
      int reading = digitalRead(switchPin); 
      if (reading == LOW) {
        Serial.println("Motor Stopped");
        break;
      }

could I simplify to this?

while(digitalRead(switchPin) == HIGH) {}
     Serial.println("Motor Stopped");

Or is it not good to put all that condition inside the while statement? Thanks

SouthernAtHeart: This is what I normally do:

while(1) {
      int reading = digitalRead(switchPin); 
      if (reading == LOW) {
        Serial.println("Motor Stopped");
        break;
      }

could I simplify to this?

You could simplify to this:

while(1) 
{
  if (!digitalRead(switchPin)) 
  {
    Serial.println("Motor Stopped");
    break;
  }
}

Loops constructed with while(1) and break always look ugly to me. If you are looping waiting for something to happen why not use that as the while condition ?

while (!digitalRead(switchPin))
{
}
Serial.println("Motor Stopped");

Why wait? Just use IF. If the condition isn't met yet, perhaps it will be next time through the loop.

As usual when presented with a code snippet we don't know all the facts. Perhaps the OP will enlighten us.

In general a while loop that is waiting for a condition is looking up the rest of the system, just like calling delay(). Look at the BlinkWithoutDelay example...

MarkT: In general a while loop that is waiting for a condition is looking up the rest of the system, just like calling delay(). Look at the BlinkWithoutDelay example...

Yes, the if statement won't work for the while statement in my case.

UKHeliBob: Loops constructed with while(1) and break always look ugly to me. If you are looping waiting for something to happen why not use that as the while condition ?

while (!digitalRead(switchPin))
{
}
Serial.println("Motor Stopped");

I like it! Thanks. Not that any one particular way is better, but I like neat & concise.