Arduino Bluetooth RC car project

Building an Arduino Bluetooth RC car is the perfect project that will help beginner grasp the whole concept of what it is like working with the Arduino board. And couple to the later fact, this project is super fun and will help you feel a lot more confident when you get it right.

I will recommend you check this Arduino project in which we use this same concept and almost the same components to build a 100% autonomous robot.

This project is all about building an RC controlled car which you can use your Android phone to control via Bluetooth using this app.

Building an Arduino Bluetooth RC car

Here is the list of parts we need:

When you have all of the components, use the schematic below to make the wiring.

We don’t have to connect the RX port of the Bluetooth module to the Arduino because we will only transmit data from the Bluetooth module to the Arduino, not the other way around.

The red cables are +5V and the blue cables are GND (Ground) on the schematic. The motors are connected to the screw terminals on the motor driver.

The program

The program uses Serial to get data from the Bluetooth module and then based on the letter that is sent over Bluetooth to the Arduino, it chooses what to do. If there is no letter sent, it stops the motors.

//speed of motors betwen 0 and 255, if you like you can change it
int pwm_speedA = 255;
int pwm_speedB = 240;
char command;

void setup() {
Serial.begin(9600);
//pins for motor controller
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(3, OUTPUT);

}

void loop() {

if(Serial.available() > 0){
command = Serial.read();
motors_stop();
switch(command){
case 'F':
forward();
break;
case 'B':
backward();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}

}

// function for driving straight
void forward(){
digitalWrite(10, HIGH);
digitalWrite(11, LOW);

digitalWrite(9, HIGH);
digitalWrite(6, LOW);

analogWrite(5, pwm_speedA);
analogWrite(3, pwm_speedB);
}

//function for reversing
void backward(){

digitalWrite(10, LOW);
digitalWrite(11, HIGH);

digitalWrite(9, LOW);
digitalWrite(6, HIGH);

analogWrite(5, pwm_speedA);
analogWrite(3, pwm_speedB);
}

//function for turning left
void left(){
digitalWrite(11, LOW);
digitalWrite(10, LOW);

digitalWrite(9, HIGH);
digitalWrite(6, LOW);

analogWrite(3, 0);
analogWrite(5, pwm_speedA);
}

//function for turning right
void right(){
digitalWrite(10, HIGH);
digitalWrite(11, LOW);


digitalWrite(9, LOW);
digitalWrite(6, LOW);

analogWrite(3, pwm_speedB);
analogWrite(5, 0);

}

//function for stopping motors
void motors_stop(){

digitalWrite(11, LOW);
digitalWrite(10, LOW);

digitalWrite(9,LOW);
digitalWrite(6, LOW);

analogWrite(5, 0);
analogWrite(3, 0);
}

To power it I used an 11.1V battery and as you can see, it is super fast even though it is not fully charged.

The range of Bluetooth communication is around 30 meters but it is good enough for a small car like this one.

To connect to your robot just turn it on, open the app and connect to your car by clicking on the gear, choose to connect to the robot and choose your Bluetooth module (HC05 or HC06 probably). Now you can just enjoy your self made RC Bluetooth car.

That’s all for this tutorial. Hope you’ve enjoyed. Having questions? feel free to ask.

tchouken2

Related Posts