Error: break statement not within loop or switch

I keep getting this error, but it's literally within the only 3 or 4 lines applying to this while loop:

code:

while ( digitalRead(WFBT_PIN) == HIGH );  //enters this loop when reset button is held
{
  delay(5000); // wait 5 seconds
  WiConfig=1;  //trigger variable to enter WiFi mode if the trigger is still reading high
  delay(10000); // wait an additional 10 seconds
  TotalReset = 1;  //trigger variable to enter a loop that will wipe and RESET the device if still high
  break;
}
while ( digitalRead(WFBT_PIN) == HIGH );

One character too many in that statement

I'm assuming you're talking about the double = sign, as that's something I went back an forth on,

but isn't a single = an assignment, while == is a comparison?

Meaning the double sign is correct. since I want the while loop to continue only when the pin is high?

EDIT: OH GOD IM BLIND. DONT ANSWER THAT. JUST TAKE THE PLUS KARMA AND LET ME CRY

Actually I meant the semicolon at the end. It is the only code that executes when the test returns true and it terminates the while. The remaining code in the code block is executed unconditionally, hence the break; is not in a while loop

Delta_G:
By the way, what’s the point of a while loop if you’re going to break it on the first run through? Couldn’t that just be an if statement?

A good question and the answer is - the code isn't completely written yet. :slight_smile: