Arduino Uno + Motor Shield Power by four 9V Batteries Not Working Properly

Hi,

I have created a Arduino Uno RC Car project with Motor Shield and HC05 Bluetooth Module which is powered by four 9V Batteries. I have done everything correct like the wires are setup appropriately, Motor Shield is fixed properly, all the motors are connected to motor shield properly, Bluetooth is working fine. Code given Below is uploaded Successfully. I can connected to car but as soon as I give it first command all the motors start to move and they never stop unless the batteries are disconnected. I have searched all this forum but not found exact solution for my problem. I am creating a school project and highly rely on this to pass my project. Tried many things but nothing seems to be working. Any efforts for resolving this issue will be appreciated. Thank you. Please forgive If done any mistake while posting to this forum.

//Arduino Bluetooth Controlled Car Video - https://www.youtube.com/watch?v=BbASlFelJSQ //
//// Before uploading the code you have to install the necessary library//
//AFMotor Library https://learn.adafruit.com/adafruit-motor-shield/library-install //

#include <AFMotor.h>

//initial motors pin
AF_DCMotor motor1(1); 
AF_DCMotor motor2(2); 
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

char command; 

void setup() 
{       
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop(){
  if(Serial.available() > 0){ 
    command = Serial.read(); 
    Stop(); //initialize with motors stoped
    //Change pin mode only if new command is different from previous.   
    //Serial.println(command);
    switch(command){
    case 'F':  
      forward();
      break;
    case 'B':  
       back();
      break;
    case 'L':  
      left();
      break;
    case 'R':
      right();
      break;
    }
  } 
}

void forward()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(255);//Define maximum velocity
  motor3.run(FORWARD); //rotate the motor clockwise
  motor4.setSpeed(255);//Define maximum velocity
  motor4.run(FORWARD); //rotate the motor clockwise
}

void back()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(BACKWARD); //rotate the motor anti-clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
  motor4.setSpeed(255); //Define maximum velocity
  motor4.run(BACKWARD); //rotate the motor anti-clockwise
}

void left()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(BACKWARD); //rotate the motor anti-clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(FORWARD);  //rotate the motor clockwise
  motor4.setSpeed(255); //Define maximum velocity
  motor4.run(FORWARD);  //rotate the motor clockwise
}

void right()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
  motor4.setSpeed(255); //Define maximum velocity
  motor4.run(BACKWARD); //rotate the motor anti-clockwise
} 

void Stop()
{
  motor1.setSpeed(0); //Define minimum velocity
  motor1.run(RELEASE); //stop the motor when release the button
  motor2.setSpeed(0); //Define minimum velocity
  motor2.run(RELEASE); //rotate the motor clockwise
  motor3.setSpeed(0); //Define minimum velocity
  motor3.run(RELEASE); //stop the motor when release the button
  motor4.setSpeed(0); //Define minimum velocity
  motor4.run(RELEASE); //stop the motor when release the button
}

You should read the "How to use this forum - please read." at the top of the discussion list.

Are those 9V batteries of the PP3 type? They are quite useless in the Arduino world. I suggest to replace them by a pack of AA type batteries.

sterretje:
Are those 9V batteries of the PP3 type? They are quite useless in the Arduino world. I suggest to replace them by a pack of AA type batteries.

Yes they are from PP3 type. Ok i will try using AA batteries with it and post an update to this thread. Thank you

Ok I have tried using 4 1.5V AA batteries to power up the motors but they aren't even moving now. Please suggest me I have seen other projects using 3.7V Li ion 10000mAH battery to run this car so should i try the same. One thing that is not being clear to me is that why is this issue being caused by batteries?

Attache a wiring diagram. You can use pen and paper and picturing it.
You use 4 pices of 9 volt battories…. How are they connected?
If all motors start and don't stop it can be a bug in the code or, electrical noise issue or something else.

Hi,
Welcome to the forum.

Do you have DMM to measure voltages around your project?

Thanks.. Tom... :slight_smile:

4x1.5V = 6V, quite a bit shy from 9V, but a lot more than 3.7V.

Why are you even trying to power a porject that is apparently designed for 3.7V (as you say a 3.7V battery powers them fine) at more than double that voltage? That may very well explain why your motors are not running even now: maybe the much higher voltage your electronics were exposed to damaged it.

Of course this is all guesswork without seeing a complete schematic, with clear specification of all components involved (and no, a Fritzing image doesn't qualify).