6wd RC Car

Hello, new to this forum and new to Arduino. I am trying to build a 6wd Rc car. I am using a Arduino Mega 2560, 3 L293d motor control IC’s, 6 DC geared motors(4.5-6v), and a HC-05 bluetooth module. I have the car wired so that the Arduino and bluetooth module both turn on. I have checked my circuit numerous times to see if any wires have been misplaced. When I try to control the car with the Android Arduino BT joystick, nothing will happen. The links to the code and schematic will be attached below. Any help will be greatly appreciated. Thanks.

Code.txt (2.71 KB)

Do you know if the robot is even getting your commands? Have you tried to debug the robot yet?

How would I check to see if it is receiving the commands. Thanks.

Your robot shows that it can print the data. Serial.println(BT.read());

however, even this is wrong. If you are sending only one character and have already read that character, then this one will not show you anything.

Do this instead. Serial.println(command);

Ok, I will try that, do you see anything else in the code that could cause an issue. Thank you.

I can barely see your code. Putting the code in a txt file compacts it. Just copy and paste the code here and please use code tags. Look for the <> symbol above the smiley faces.

#include <SoftwareSerial.h>
int command;
SoftwareSerial BT(11, 10); //TX, RX respetively

#define motora1 24
#define motora2 25

#define motorb1 32
#define motorb2 33

#define motorc1 28
#define motorc2 29

#define motord1 26
#define motord2 27

#define motore1 23
#define motore2 22

#define motorf1 31
#define motorf2 30

void setup()
{
  Serial.begin(9600);
BT.begin (9600); 

pinMode(motora1, OUTPUT);
pinMode(motora2, OUTPUT);
pinMode(motorb1, OUTPUT);
pinMode(motorb2, OUTPUT);
pinMode(motorc1, OUTPUT);
pinMode(motorc2, OUTPUT);
pinMode(motord1, OUTPUT);
pinMode(motord2, OUTPUT);
pinMode(motore1, OUTPUT);
pinMode(motore2, OUTPUT);
pinMode(motorf1, OUTPUT);
pinMode(motorf2, OUTPUT);

pinMode(13,OUTPUT);
} 

void loop() {

if (BT.available() > 0) {

command = BT.read();

Serial.println(command);
delay(50);
switch (command) {

case '1' : 

forward();

break;

case '0' : 

freeze();

break;

case '2' : 

reverse();

break;

case '3' : 

left();

break;

case '4' : 

right();

break;

}
}
}

void forward()
{
digitalWrite(motora1,HIGH);
digitalWrite(motora2,LOW);

digitalWrite(motorb1,HIGH);
digitalWrite(motorb2,LOW);

digitalWrite(motorc1,HIGH);
digitalWrite(motorc2,LOW);

digitalWrite(motord1,HIGH);
digitalWrite(motord2,LOW);

digitalWrite(motore1,HIGH);
digitalWrite(motore2,LOW);

digitalWrite(motorf1,HIGH);
digitalWrite(motorf2,LOW);
}

void reverse()
{
digitalWrite(motora1,LOW);
digitalWrite(motora2,HIGH);

digitalWrite(motorb1,LOW);
digitalWrite(motorb2,HIGH);

digitalWrite(motorc1,LOW);
digitalWrite(motorc2,HIGH);

digitalWrite(motord1,LOW);
digitalWrite(motord2,HIGH);

digitalWrite(motore1,LOW);
digitalWrite(motore2,HIGH);

digitalWrite(motorf1,LOW);
digitalWrite(motorf2,HIGH);
}

void freeze()
{
digitalWrite(motora1,LOW);
digitalWrite(motora2,LOW);

digitalWrite(motorb1,LOW);
digitalWrite(motorb2,LOW);

digitalWrite(motorc1,LOW);
digitalWrite(motorc2,LOW);

digitalWrite(motord1,LOW);
digitalWrite(motord2,LOW);

digitalWrite(motore1,LOW);
digitalWrite(motore2,LOW);

digitalWrite(motorf1,LOW);
digitalWrite(motorf2,LOW);
}

void left()
{
 digitalWrite(motora1,HIGH);
digitalWrite(motora2,LOW);

digitalWrite(motorb1,LOW);
digitalWrite(motorb2,HIGH);

digitalWrite(motorc1,HIGH);
digitalWrite(motorc2,LOW);

digitalWrite(motord1,LOW);
digitalWrite(motord2,HIGH);

digitalWrite(motore1,HIGH);
digitalWrite(motore2,LOW);

digitalWrite(motorf1,LOW);
digitalWrite(motorf2,HIGH);

}

void right()
{
 digitalWrite(motora1,LOW);
digitalWrite(motora2,HIGH);

digitalWrite(motorb1,HIGH);
digitalWrite(motorb2,LOW);

digitalWrite(motorc1,LOW);
digitalWrite(motorc2,HIGH);

digitalWrite(motord1,HIGH);
digitalWrite(motord2,LOW);

digitalWrite(motore1,LOW);
digitalWrite(motore2,HIGH);

digitalWrite(motorf1,HIGH);
digitalWrite(motorf2,LOW);

}

Better, there are some format issues, like the 3 closing brackets directly above each other, but its readable.

So it must be another issue other than the code.

What are you receiving?

Not sure what you mean by that.

Your sending something from the remote, right? Well what is the robot receiving when you use the serial monitor?

The serial monitor isn't receiving anything. Probably a really stupid question but can I type a command into the serial monitor to see if the RC car wheels will spin or anything.

You would need to change the code to serial.available() and command = Serial.read(), instead of BT.available and .read.

An error message of serial not declared in this scope.

Ok I managed to get it to verify and upload what could I enter into the serial to see if it will spin. Thank you.

It works, thank you very much for all the help.

Great, now lets see what the remote is actually sending. Do you know if the remote and the robot are paired together?

When I connect the bluetooth module and try the app, nothing comes up in the serial monitor when a command is pressed.

What bluetooth module are you using on your robot, can you post a link?