Motor is not rotating when operated via bluetooth

Hello,
I am controlling a 2 wheel drive car using a Johnson 30 RPM motor which is connected to an Arduino Uno via a L298N dual H-Bridge motor driver. I am giving the driver a supply of 12V. I am using a bluetooth app to control the direction of the car. When I try to operate the car only one of the wheels is rotating at a time. I tested the same code using a 12V 100 RPM BO motor and it worked just fine. Could the issue be with the driver I am using. I initially tested using the 2A L298N driver and later switch to the L298N dual H-bridge driver. I tried powering the driver using a 12V 2A adaptor as well as a DC power supply.
The components I am using are:

  1. Arduino UNO
  2. HC-05 Bluetooth Module: https://robu.in/product/hc-05-6pin-bluetooth-module-with-button/
  3. 30 RPM Johnson Motor: https://robu.in/product/grade-a-quality-orange-12v-30-rpm-johnson-geared-dc-motor/
  4. L298N Dual H-Bridge driver: https://robu.in/product/l298n-dual-h-bridge-dc-stepper-motor-driver-controller-module/
  5. Bluetooth app: https://play.google.com/store/apps/details?id=braulio.calle.bluetoothRCcontroller&hl=en_IN&gl=US

Code:

int enA = 9;
int enB = 11; 
int vspeed = 0;
char a;

void setup()
{
  pinMode(2, OUTPUT);  //Left motors forward
  pinMode(3, OUTPUT);  //Left motors reverse
  pinMode(4, OUTPUT);  //Right motors forward
  pinMode(5, OUTPUT);  //Right motors reverse
  pinMode(enA, OUTPUT); //enA
  pinMode(enB, OUTPUT); //enB
  Serial.begin(9600);
}

void loop()
{

  if (Serial.available())
  {
    a = Serial.read();
    Serial.println(a);
  }

  if (a == '0') {
    vspeed = 10;
  }
  else if (a == '1') {
    vspeed = 25;
  }
  else if (a == '2') {
    vspeed = 50;
  }
  else if (a == '3') {
    vspeed = 75;
  }
  else if (a == '4') {
    vspeed = 100;
  }
  else if (a == '5') {
    vspeed = 125;
  }
  else if (a == '6') {
    vspeed = 150;
  }
  else if (a == '7') {
    vspeed = 175;
  }
  else if (a == '8') {
    vspeed = 200;
  }
  else if (a == '9') {
    vspeed = 225;
  }
  else if (a == 'q') {
    vspeed = 255;
  }

  analogWrite(10, vspeed);
  analogWrite(11, vspeed);

  if (a == 'F') //Forward
  {
    digitalWrite(2, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
  }

  else if (a == 'B')  //Reverse
  {
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(2, LOW);
    digitalWrite(4, LOW);
  }

  else if (a == 'L')  //Left 
  {
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(2, LOW);
    digitalWrite(5, LOW);
  }

  else if (a == 'R')  //Right
  {
    digitalWrite(2, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }

  else if (a == 'G')  //Left forward
  {
    digitalWrite(2, LOW);
    digitalWrite(4, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
  }

  else if (a == 'H')  //Left reverse
  {
    digitalWrite(2, LOW);
    digitalWrite(5, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }

  else if (a == 'I')  //Right forward
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  }

  else if (a == 'J')  //Right reverse
  {
    digitalWrite(3, HIGH);
    digitalWrite(2, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  }

  else if (a == 'S')  //Stop
  {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  }
}

Hi,
Do you have a DMM to measure some circuit parameters?

Can you also post a copy of your circuit diagram?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Yes I do. What parameters would you like to know?

Hi,

What voltages do you measure across the motors when they operate?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

 pinMode(2, OUTPUT);  //Left motors forward
  pinMode(3, OUTPUT);  //Left motors reverse
  pinMode(4, OUTPUT);  //Right motors forward
  pinMode(5, OUTPUT);  //Right motors reverse

It would be better to give your pins variable names

 byte LeftFwdPin = 2;
 byte LeftRevPin = 3;
 byte RightFwdPin = 4;
 byte RightRevPin = 5;


  pinMode(LeftFwdPin, OUTPUT);  //Left motors forward
  pinMode(LeftRevPin, OUTPUT);  //Left motors reverse
  pinMode(RightFwdPin, OUTPUT);  //Right motors forward
  pinMode(RightRevPin, OUTPUT);  //Right motors reverse

Tom... :smiley: :+1: :coffee: :australia:

12V across the main supply, 9V across the motor that works and 0V across the one that doesn't. I have also checked the voltage supplies of the enable and the IN pins of the driver. The enable gives around 3-4 (since it's connected to a PWM pin for speed control) and the IN pin gives close to 5V.

Okay i"ll do that.

Constants or #defines

Hi,
What happens if you just write hard code to make the motors cycle fwd and rev, no monitor control.

Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.