Programme running without initialization command

My program runs without initialization, according to my design, until Bluetooth is working, should the program run, but, instead, the program just runs, here is the code

Thanks in advance for your reply

Obstacle_avoidance_Robot.ino (2.78 KB)

Can you not post the code inline? I'm on a phone here so I can't open it.

From the words you use, I can suggest an alternative. Do not try to stop the sketch. It should be always running, watching the sensors and listening for commands. If the command is "stop" then stop the motors, don't stop the sketch.

Before the first command arrives, is it so hard to store a dummy 'previous' command of "stop"?