Bluetooth controlled car fault in catching signals

I know only programming basics but I wanted to make a Bluetooth controlled car for my first semester project in BSCS. Everything is working but there seems to be some problem. When I'm starting the car it's moving but with a delay. Like I'll press the button but the car will move after a second or two. Someone please help me troubleshoot the problem.

This is the code I used from a website

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);
}

How fast can you see and print the characters that your are Bluetooth int over to the Arduino without worrying about doing anything except just that…

It may be that you can only get characters over your link so fast.

There doesn't at a glance seem to be anything keeping your program very responsive (well, keeping in mind the 100 millisecond delay slowing the loop down).

Try just getting and printing the characters, worry about all the motor control stuff for the moment.

Also, here and elsewhere you say

right side motors rotate in forward direction, left side motors doesn't rotate)

Wouldn't you have to write LOW to the other motor control pins?

Oh, welcome to the community!

a7

Please explain more about the bluetooth implementation. What is sending the command character? What is receiving?

If you run the car with input from the serial monitor and not the bluetooth module, do you see the delays in the motor movement?

@cattledog haha, we divide to conquer. Which piece you look into first is up to you.

a7

The car is full of faults :sob: idk why I decided to make this. I feel dumb asf. Idk whether the code that website gave me was right or wrong. I just wanted to build a Bluetooth controlled car because it looked cool. So I did whatever was mentioned in the website.

https://create.arduino.cc/projecthub/samanfern/bluetooth-controlled-car-d5d9ca

I used:
arduino uno board,
hc-05 Bluetooth module,
L298 bridge motor driver,
and 12 V battery
Dc gear motors

Before it was just the delay causing problems but now only two of my wheels are working. Like if I stop the two forward wheels the backward wheels would work but if I press the forward button on the mobile app only forward wheel work not the backward wheels when in fact both should work. I feel like maybe the wires are broken from inside??

There's also one more I did that is not from the website and that is that I connected the battery to arduino directly and soldered motor driver to the battery. It is my first time soldering.

Please see the image I'm attaching.

Please help without making me feel more dumb than I already am feeling :sob::sob:


The circuit I was supposed to follow

Don't be too hard on yourself. Projects usually don't work as expected at first go, and working your way through this will be a good learning experience.

It's best to break the project down into smaller pieces.

I would recommend that for development you disconnect the HC05 and take your input from the Serial monitor. Once that is working, substituting bluetooth over the serial port is trivial.

You need to verify the motors work with simple test code to just run the motors.

You shouldn´t. Each one of us started once and chose to do much more easy-to-do projects.

I agree with @cattledog on trying to accomplish smaller steps. But looking at your picture, looks like you´re feeding HC-05 module with 3.3V (blue wire). That´s not enough. This module requires at least 3.6V to work properly. Take a look on that. :wink:

If this works, be aware that RX line of HC-05 is 3.3V. Then you should use a voltage divider or a logic level converter on this line. It might work without it, but there´s a risk in burning out the HC-05.

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