My robot is stacked after disconnect Bluetooth

Hello guys..!!

I am using: arduino UNO - Motor shield 3V - bluetooth - and ultrasonic sensors

void loop() {
if(Serial.available() > 0){
state = Serial.read();
switch(state){
case 'F':
...... (rest cases)
else {
ReadSensors ();
AvoidWalls ();
MoveRobot ();
}

When power my robot it start perfect, it moves, read sensors and he moving nice avoiding walls all its ok. when i connect my phone with my robot, it connect fine and everything work fine BUT when i disconnect it, my robot is stack, doing nothing. (if i connect again my phone its work fine).

Any ideas?

Sorry for bad English.

Any ideas?

Yes. Post ALL of your code.

i am asking if i had to change something in main loop ( for this i post only this code because when i power my robot or reset it, it moving fine with no problem)

void loop() {
if(Serial.available() > 0){
state = Serial.read();
switch(state){
case 'F':
...... (rest cases)
else {
ReadSensors ();
AvoidWalls ();
MoveRobot ();
}

all code is huge mate.

all code is huge mate.

Either reduce the size of the code to something smaller that illustrates the problem or post it anyway.

Why are you disconnecting the other device while trying to control the robot with it?