(Fixed!!) HC-05 now connecting to motorshield!

So i’m trying to program a RC car using Bluetooth, and to do so I have my bluetooth module, the HC-05 (RS232) and a motorshield L293D.

The car has 2 motors and I have all the connections ready, but I’m not being able to have the HC-05 working as I want.

I connect the HC-05 with my smartphone easily, but when I connect the Rx and Tx pins to the motorshield, the HC-05 loses connection. I need help because im pretty sure the error is on the programming and I’m not being able to figure it out.

Below is the code im using for the project, would appreciate any help I can get!

#include <SoftwareSerial.h>
 #include <AFMotor.h>
  
  AF_DCMotor motor1(1,MOTOR12_64KHZ);
  AF_DCMotor motor2(2,MOTOR12_64KHZ);
  
  void setup()
  {
    Serial.begin(9600);
     
    motor1.setSpeed (255);
    motor2.setSpeed (255);
  
  }
  
  
  void loop()
  
  {
    char comandos;
    if(Serial.available() > 0)
    {
    
    comandos = Serial.read();
    
    if(comandos == '1')
    
    {
      motor1.setSpeed (50);
      motor2.setSpeed (50);
    }
    
    if(comandos == '2')
    
    {
      motor1.setSpeed (75);
      motor2.setSpeed (75);
    }
    if(comandos == 'F')
    
    {
      motor1.run(FORWARD);
         
    }
    
    else if(comandos == 'B')
    
    {
      motor1.run(BACKWARD);
    }
    else if(comandos == 'R')
    {
      motor2.run(BACKWARD);
    }
    else if(comandos == 'L')
    {
      motor2.run(FORWARD);
    }
   }
  }

Check the stickies about properly listing code between code tags </>.

If you really have a kosher connection, no amount of code will break it, unless there is a specific instruction to do so. So it sounds like power, or wiring.

Getting a connection with the phone and then make the connection serial to Arduino sounds really weird, and something nobody would do in reality. I’m not even sure it is relevant, but I have to ask why would you do that.

It sounds like you are using hardware serial, and therefore you can test the code without bluetooth connected by sending the command from the serial monitor. Note that doing this may conceal a power problem.

Posting a diagram of the wiring and power would be a good idea.

i'll send the wire connections tomorrow.

But the point of the project is to control the RC car with a smartphone, if you have (and probably do) a better idea of how im supposed to go towards that goal, i'll gladly listen.

thank you!

DouradaGrelhada:
But the point of the project is to control the RC car with a smartphone, if you have (and probably do) a better idea

I don't. What you propose sounds entirely reasonable, and it's not unique either. All you have to do is explain it properly, and do it properly.

One of the biggest threads on this forum is about bluetooth joystick. I imagine that is just what you need for a car.

Standard HC-05 does not use R(S?)232 but TTL levels. Also please provide a link to your shield.

I further suggest that you test the HC-05 with a dedicated sketch without the motorshield attached. Get a feel how it works.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

What model Arduino are you using with the motor shield?

Tom... :slight_smile:

I'm currently using the Arduino UNO model and a L293D motorshield.

I'm also using the android app "Bluetooth RC controller" as interface. I have seen lot's of guides on the internet with the same application and they all seem to work on their projects, but not on mine.

Here's a display of the connections im using:

I think the main problem is me not knowing how to use the bluetooth device, as in the many tutorials I studied, they didn't even mention the serial monitor, and lot's of people here talk about it.

Take the motor shield out of play, and just address bluetooth first. You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

You probably haven't done any damage but it is good practice to use a 1k/2k voltage divider in Uno Tx line.

I'll try the to play with the serial monitor and i'll give you some feedback later. Thanks Guys!

DouradaGrelhada:
I’ll try the to play with the serial monitor

That’s a good start. Leave bluetooth disconencted and you can test everything with the serial monitor. No change of code required when you reconnect Bluetooth.
Your command

#include <SoftwareSerial.h>

appears to be redundant, which is probably just as well.

Here to say that I actually got the RC car to work at my will, the link about bluetooth really helped me out there and I really appreciate your support.

Thanks a lot!

Hi,
Good to hear.
Can you tell us what you had to do to solve the problem please, it will make this thread of use to someone else who may get your problem.

Thanks... Tom... :slight_smile:

I actually just made the connection between the Smartphone and the Bluetooth module, step by step with the link that was suggested to me - http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf -

Don't know if it might have been just a misunderstanding between both of them, still not sure.

Still appreciate the help I got here!

HC05 need to be level converted to 3.3 v to feed to Rx pin of Arduino but not necessary for TX pin, are you doing that.

Other way round. See reply #7

I've updated the title, I got the car to work!