RC car controlled with bluetooth and arduino motorshield rev 3

Hello,

I am pretty new to arduino and need some help pls.

I am trying to make an RC car with arduino motor shield R3 and wich is controlled with bluetooth.
I use arduino uno, motorshield R3, HC-06 bluetooth, 1 DC motor and 1 servo motor.

My question is:

  1. How can I get the car moving forward and at the same time turning?
  2. How can I steer these commands from an app at my android phone?

Pls help I am really stuck and greatful for all the help I get :smiley:

You need to post your Arduino program so we can see what you can see.

...R

#include <SoftwareSerial.h>
#include <Servo.h>

SoftwareSerial BT(10, 11);
String readdata;
Servo myservo;
int bluetoothTx = 10;
int bluetoothRx = 11;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup() {
BT.begin(9600);
Serial.begin(9600);
myservo.attach(9);
Serial.begin(9600);
bluetooth.begin(9600);

int const potPin = A1;
pinMode(3, OUTPUT); // connect to input 1 of l293d
pinMode(4, OUTPUT); // connect to input 4 of l293d
pinMode(5, OUTPUT); // connect to input 3 of l293d
pinMode(6, OUTPUT); // connect to input 2 of l293d
}

void loop() {
while (BT.available()){
delay(10);
char c = BT.read();
readdata += c;
}
if (readdata.length() > 0) {
Serial.println(readdata);

if(readdata == “forward”)
{
digitalWrite(3,HIGH);
digitalWrite (4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(100);
}

else if(readdata == “reverse”)
{
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6,LOW);
delay(100);
}

else if(bluetooth.available()> 0 )
{
int toSend = bluetooth.read();
Serial.println(toSend);
myservo.write(toSend);
}

else if (readdata == “stop”)
{
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
delay (100);
}

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

Have a look at Serial Input Basics - simple reliable wasy to receive data.

Don’t use delay(). Use millis() to manage timing as illustrated in Several Things at a Time

It is generally not a good idea to use the String (capital S) class in the small memory of an Arduino. You should c stings (small s) and use the strcmp() function.

Your whole system would probably be simpler if you just send a single character for each instructions ‘S’ for Stop, ‘F’ for Forward etc.

…R

I did the same thing along time ago but instead i use a L298 driver. I will to search the code in my pc to send you. I test my code and it works fine, its steer and move forward at the same time, you can use the stering (servo) when the car moves forward or reverse.

Download Blue Control from the Google PlayStore, it send letters like F for Forward and R for Reverse. I use it.

ray9043:
I did the same thing along time ago but instead i use a L298 driver. I will to search the code in my pc to send you. I test my code and it works fine, its steer and move forward at the same time, you can use the stering (servo) when the car moves forward or reverse.

Download Blue Control from the Google PlayStore, it send letters like F for Forward and R for Reverse. I use it.

Hello,
I am sorry to bother you, but are you confident your code would work for the rev3 driver?
I am asking only because it is my understanding that usually different drivers need their own code.
I am a newbie trying to make a BB8 using rev3.

Thank you :slight_smile: