Arduino Bluetooth Controlled Car having issues with HC05 receiving signals

Hi ,

I have completed wiring of my car. I have attached the wiring image.

Components used :
L298n Motor Driver
HC05 BT module
Jumper Wires
18650 Battery Cells

The problem that I am facing is that when I send forward or backward instruction to the car it moves with 3-4 seconds delay. Sometimes, it goes in the loop. It keeps moving in the forward direction and then I have to power off to stop the current flow. I dont know if there's any coding issue. The working of hc05 looks fine as it blinks as it should be.

This is a high school project. I have to submit within 2-3 days. Kindly reply me fast.

I have put my code below

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
  pinMode(9, OUTPUT);   //Led
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    t = Serial.read();
    Serial.println(t);
  }

  if (t == 'F') {  //move  forward(all motors rotate in forward direction)
    digitalWrite(13, HIGH);
    digitalWrite(11, HIGH);
  }

  else if (t == 'B') {  //move reverse (all  motors rotate in reverse direction)
    digitalWrite(12, HIGH);
    digitalWrite(10, HIGH);
  }

  else if (t == 'L') {  //turn right (left side motors rotate in forward direction,  right side motors doesn't rotate)
    digitalWrite(11, HIGH);
  }

  else if (t == 'R') {  //turn left (right side motors rotate in forward direction, left  side motors doesn't rotate)
    digitalWrite(13, HIGH);
  }

  else if (t == 'W') {  //turn led on or off)
    digitalWrite(9, HIGH);
  } else if (t == 'w') {
    digitalWrite(9, LOW);
  }
  

  else if (t == 'S') {  //STOP (all motors stop)
    digitalWrite(13, LOW);
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
  }
  delay(100);
}

Your code looks fine if you are sending commands without line endings.

Try with the 5v from the motor driver board connected to 5v and not Vin.

What app are you using to send the command. Kai Morich's Serial Bluetooth Terminal is one of the best.

By your statements there is way TOO much unknown. Put your car up on blocks and connect the UNO to your PC and begin debugging. First print the actual message from BlueTooth rather than guessing based on light blinking. If that's ok, display other parameters until you can see something is wrong.

I also am facing these issues.

Can you please send me some recommendations also please? I am also getting these issues

Please tell me how to fix this because am also getting these problems.
Same project...

Get rid of all the "else" and just use the straight forward test for the character.

Yes sir.
Sorry for the late reply.

Please sir, can you please say these things in simpler language. I don't quite understand.

The "if", "else" type of testing is ONLY used when your "if" is a test for less than or a test for greater than. When you use "else" with an "if " test for equal you just confuse yourself.
Make all your "if" test individual, stand-alone, lines of code. Then you can more easily debug you code.

Okay sir, i understood now! Thanks a lot!!!

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