Code not saved on arduino uno

Hello
I m trying to make a 4wheel robot , bluetooth controlled
When I use cable USB I can control the robot via the app (bluetooth) but when I deplug the cable I cant control it
So I think the code isn't uploaded on the arduino (even though I get no error when uploading my code)

Any help is welcomed

The code I use :

char t;

void setup() {

pinMode(13,OUTPUT); //left motors forward

pinMode(12,OUTPUT); //left motors reverse

pinMode(11,OUTPUT); //right motors forward

pinMode(10,OUTPUT); //right motors reverse

Serial.begin(9600);

}

void loop() {

if(Serial.available()){

t = Serial.read();

Serial.println(t);

}

if(t == '1'){ //move forward(all motors rotate in forward direction)

digitalWrite(13,HIGH);

digitalWrite(12,LOW);

digitalWrite(11,HIGH);

digitalWrite(10,LOW);

}

else if(t == '2'){ //move reverse (all motors rotate in reverse direction)

digitalWrite(13,LOW);

digitalWrite(12,HIGH);

digitalWrite(11,LOW);

digitalWrite(10,HIGH);

}

else if(t == '3'){ //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)

digitalWrite(13,LOW);

digitalWrite(12,LOW);

digitalWrite(11,HIGH);

digitalWrite(10,LOW);

}

else if(t == '4'){ //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)

digitalWrite(13,HIGH);

digitalWrite(12,LOW);

digitalWrite(11,LOW);

digitalWrite(10,LOW);

}

else if(t == '5'){ //STOP (all motors stop)

digitalWrite(13,LOW);

digitalWrite(12,LOW);

digitalWrite(11,LOW);

digitalWrite(10,LOW);

}

delay(100);

}

TOPIC MOVED.

You may want to READ THIS for future reference.
It will help you get the best out of the forum.

Also the WHILE SERIAL statement is probably your issue.

Bob.

When USB cable is unplugged what is powering the system?

ballscrewbob:
Also the WHILE SERIAL statement is probably your issue.

Where do you see 'while serial' ?

Zakaofsand:
Hello
So I think the code isn't uploaded on the arduino (even though I get no error when uploading my code)

If the code was not uploaded, it would not work at all; not with USB power and not without USB power.

I don't see any obvious bluetooth related code in there, the code takes commands coming in over the Serial interface, which is normally connected to USB.

So where's your Bluetooth stuff? How is it all connected?