help with ending while loop

my project is to have Bluetooth controlled leds where when i press the button on my phone one led turns on and the other flashes; i need to end the while loop when the button is pressed again but i am having problems.
much appreciated and thanks in advance

[        if (rxValue.find("A") != -1) {
          flash = true;
          Serial.print("Turning ON!");
          digitalWrite(LED, HIGH);
          while(flash = true) {
 digitalWrite(LED2, HIGH);
 delay(100);
 digitalWrite(LED2, LOW);
 delay(100);
} 
  }



        else if (rxValue.find("B") != -1) {
          Serial.print("Turning OFF!");
          (flash = false);
          digitalWrite(LED, LOW);
          digitalWrite(LED2, LOW);
      

        }

        Serial.println();
        Serial.println("*********");
      }
    }
};]

RECENT_led_flash_bluetooth.ino (3.94 KB)

Your condition should be (flash == true). What you have now isn't doing what you think. But flash is never changed inside the loop so the loop can never finish anyway.

If you use Ctrl-T in the IDE your code will be indented properly and be a lot easier to read.

Steve

Don't use a while loop. I'm not saying never use while loops. But not like that, with long delay() Inside.

You need to master "state machine" and "blink without delay" techniques.