0

I'm trying to build Bluetooth RC car, but I can't run only one DC motor.. only both of them. Everything works fine, the bluetooth, the app but when i try to go forward/backward/left/right nothing happens, only when i run both of them. I'm running the Arduino Nano with usb cable. The bluetooth connection is stable, The DC motors are working. I don't know what I'm doing wrong. Thanks!

Schematic

const int AIA = 2;
const int AIB = 3;
const int BIA = 4;
const int BIB = 5;
byte vSpeed = 255;
int state;

void setup() {
pinMode(AIA, OUTPUT);
pinMode(AIB, OUTPUT);
pinMode(BIA, OUTPUT);
pinMode(BIB, OUTPUT);

// Initialize serial communication at 9600 bits per second:
    Serial.begin(9600);
}

void loop() {
  //Save income data to variable 'state'
    if(Serial.available() > 0){     
      state = Serial.read();  
    }


  /***********************Forward****************************/
  //If state is equal with letter 'F', car will go forward!
    if (state == 'F') {
      analogWrite(AIA, vSpeed);
      analogWrite(AIB, 0);
      analogWrite(BIA, 0);      
      analogWrite(BIB, 0); 
    }
  /**********************Forward Left************************/
  //If state is equal with letter 'G', car will go forward left
    else if (state == 'G') {
      analogWrite(AIA, vSpeed);
      analogWrite(AIB, 0);
      analogWrite(BIA, vSpeed);      
      analogWrite(BIB, 0); 
    }
  /**********************Forward Right************************/
  //If state is equal with letter 'I', car will go forward right
    else if (state == 'I') {
      analogWrite(AIA, vSpeed);
      analogWrite(AIB, 0);
      analogWrite(BIA, 0);      
      analogWrite(BIB, vSpeed); 
    }
  /***********************Backward****************************/
  //If state is equal with letter 'B', car will go backward
    else if (state == 'B') {
      analogWrite(AIA, 0);
      analogWrite(AIB, vSpeed);
    }
  /**********************Backward Left************************/
  //If state is equal with letter 'H', car will go backward left
    else if (state == 'H') {
      analogWrite(AIA, 0);
      analogWrite(AIB, vSpeed);
      analogWrite(BIA, vSpeed);      
      analogWrite(BIB, 0);
    }
  /**********************Backward Right************************/
  //If state is equal with letter 'J', car will go backward right
    else if (state == 'J') {
      analogWrite(AIA, 0);
      analogWrite(AIB, vSpeed);
      analogWrite(BIA, 0);      
      analogWrite(BIB, vSpeed);
    }
  /***************************Left*****************************/
  //If state is equal with letter 'L', wheels will turn left
    else if (state == 'L') {
      analogWrite(BIA, vSpeed);      
      analogWrite(BIB, 0); 
    }
  /***************************Right*****************************/
  //If state is equal with letter 'R', wheels will turn right
    else if (state == 'R') {
      analogWrite(BIA, 0);      
      analogWrite(BIB, vSpeed);   
    }
  /************************Stop*****************************/
  //If state is equal with letter 'S', stop the car
    else if (state == 'S'){
      analogWrite(AIA, 0);
      analogWrite(AIB, 0);
      analogWrite(BIA, 0);      
      analogWrite(BIB, 0);
    }
}
  • What is meaning "The DC motors are working." ? Are you able to control one DC motor using your analogWrite() calls ? – J. Piquard Nov 27 '16 at 19:19
  • Most likely unrelated, but... You can only use analogWrite (PWM) on pins 3, and 5. Also the backwards section seems to be missing settings for BIA and BIB. – Gerben Nov 27 '16 at 19:22
  • It means that are functional. The thing is i can't run only one of them.. only both of them at the same time. – Tux Nov 27 '16 at 19:22
  • AIA and AIB ar for forward and backward, BIA and BIB for left and right. that's why it's missing at backward.. i don't need to run the left and right motor – Tux Nov 27 '16 at 19:24
  • Which cases work? graphics-wise board looks like some sort of a dual L9110S thing. Is it like bananarobotics.com/shop/… ? Does the board work as expected if you jumper it up manually? – Dave X Nov 27 '16 at 19:31
1

Connect the Nano ground to the driver board ground. Since they do not share a common ground, they can have odd behavior as their ground planes float.

You need only connect the grounds, the USB can still provide +5 to the Nano, and the +9 can still provide power to the driver. The only energy that will flow through the black wire connecting the grounds is the energy that flows between pins 2,3,4,5 and the driver's AIA, AIB, BIA, BIB, for the logic signals, which I'd bet is in the sub-uA range.

  • If I connect the gnd of the driver to nano, then i have to connect the nano gnd to batteries (i e black wire) right? Then i have nano and driver sharing the same power source. But i want to make the driver run on 9v batteries alone and the nano on another power source. So i can have full power to motors. Is it wrong? How am i supposed to make the circuit to achieve what i said? – Tux Nov 28 '16 at 7:21
  • One more thing. If i connect the nano with usb power source and the driver to nano (gnd and 5v) everything works fine but the motors aren't receiving enough power. The problem is when I'm separating the power sources and make the motors run on their own power, that's when i get the behavior.. – Tux Nov 28 '16 at 7:29
  • Yep, just the black wire. See update above. No need to power the Nano with the +9 if you do not want to. – Dave X Nov 28 '16 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.