Arduino Motor Shield LEDs only flash when using bluetooth but not through USB

So I'm trying to build a telepresence robot that's controlled through bluetooth. I got the bluetooth working and it receives the input but if it's only powered by batteries (9V) the motor's status LED flash when input is given but if I have the arduino connected to the pc through USB and still send the input through bluetooth it receives it and acts on it properly. I tried adding a battery to the arduino dc power jack, so there would be one 9V battery on the motor shield and another on the arduino and I still get the same result. Any ideas?

Here's the code in case it's software related:

char val;

int dirB = 13;
int dirA = 12;
int pwmB = 11;
int pwmA = 3;
int breakA = 9;
int breakB = 8;

void setup(){
 pinMode(dirB, OUTPUT);
 pinMode(dirA, OUTPUT); 
 pinMode(pwmB, OUTPUT); 
 pinMode(pwmA, OUTPUT);
 pinMode(breakA, OUTPUT); 
 pinMode(breakB, OUTPUT); 
 
 Serial.begin(9600);
}

void loop(){
  if( Serial.available() )       
  {
  val = Serial.read();
  Serial.print(val);  
  }
  if(val == '0'){   //Robot is breaking            
    digitalWrite(breakA, HIGH);
    digitalWrite(breakB, HIGH);
    analogWrite(pwmA, 0);
    analogWrite(pwmB, 0);
  }

  if(val == '1'){    //Robot is going Foward
    digitalWrite(breakA, LOW);
    digitalWrite(breakB, LOW);
    digitalWrite(dirA, HIGH);
    digitalWrite(dirB, LOW); 
    analogWrite(pwmA, 255);
    analogWrite(pwmB, 255); 
  }  
    
  if (val == '2'){    //Robot is going Backwards
    digitalWrite(breakA, LOW);
    digitalWrite(breakB, LOW);
    digitalWrite(dirA, LOW);
    digitalWrite(dirB, HIGH); 
    analogWrite(pwmA, 255);
    analogWrite(pwmB, 255); 
  }
  
  if (val == '3'){    //Robot is going Right
   digitalWrite(breakA, LOW);
   digitalWrite(breakB, LOW);
   digitalWrite(dirA, HIGH);
   digitalWrite(dirB, HIGH); 
   analogWrite(pwmA, 255);
   analogWrite(pwmB, 255); 
  }
  
  if (val == '4'){    //Robot is going Left
   digitalWrite(breakA, LOW);
   digitalWrite(breakB, LOW);
   digitalWrite(dirA, LOW);
   digitalWrite(dirB, LOW); 
   analogWrite(pwmA, 255);
   analogWrite(pwmB, 255); 
  }
  
  
}

It might help if you provide links to the used hardware and a wiring diagram if you used anything else than just Arduino shields.

I'm using the arduino motor shield :

and this bluetooth shield:
http://imall.iteadstudio.com/im120417010.html
Nothing else really. BT on top of motor shield on top of arduino.

Can you specify again what your problem is? I'd interpret your description to have both setups (Bluetooth and USB) working correctly. What Arduino are you using?

My problem is that if I use the bluetooth shield to control the motor shield (through an android app) it won't work unless it's also connected to a computer through USB. And when I send the input that would get the motors running, the 4 status LEDs for the motors blink (when not connected through usb) and I hear a sort of click. I have an arduino uno r3.

Thanks for your help

What kind of 9V battery are you using? A standard block battery? That probably don't provide enough current for the motors. Please provide links to the motors you connected to the shield. And if you use another battery, provide a link to it.

I'm using a block 9V battery powering two of these motors:

At first I thought that the 9V battery wasn't enough for both the motors and the bluetooth shield so I bought a dc jack so I could plug another 9V battery to the arduino but the problem persisted. The thing is even without a battery (only using the usb port to power it) the motors run fine (a bit slower, of course) and I can send the input through bluetooth.

Try powering the motor shield with a 9V power supply that is able to deliver 5A (that's about the stall current of two of these motors). USB is almost enough to power two motors with absolutely no load on it, the 9V block battery probably doesn't even have enough power for one motor without load. In that case the voltage drops below a point where either the Arduino or the bluetooth module won't work correctly anymore.