In this tutorial, we will learn how to make an Arduino Bluetooth Control car. This is controlled by an Android mobile. The connection is via Bluetooth. This is also a popular robot car made with Arduino. The specialty of this is that the front light, rear light and a horn that emits a beep sound can be controlled by Bluetooth app. Front light, rear light, and horn are optional things of Arduino Bluetooth RC Car. Arduino Bluetooth RC car can be made without front light, back light and horn. No need to modify Arduino code.
You can watch the following video or read the written tutorial below.
Overview
In this project overview, we introduce the Arduino Bluetooth car, a mobile-controlled robotic vehicle created with Arduino technology. The Android app serves as the primary interface for controlling the car through Bluetooth communication. Resembling an RC car, it offers functionalities such as horn activation, front and back lights, and speed adjustment. The wireless control extends up to a maximum range of 15m-20m, providing flexibility and convenience in maneuvering the vehicle.
Components Needed
Before we begin, make sure you have gathered all the necessary components. The purchase links are in the description of my YouTube video.
- Arduino Uno or compatible board
- 4-wheel chassis kit with DC motors
- L298N motor driver module
- HC-05 or HC-06 Bluetooth Module
- Jumper wires
- Two 18650 Rechargeable Battery 3.7V
- 18650 Li-ion Battery Holder 2-Way
- Toggle Switch
- USB cable for programming the Arduino
- Screwdriver and assorted screws
- Glue Gun
- Front and back lights (LEDs)
- 5V buzzer (for the car horn)
**Optional:** You can also include additional features like a smartphone holder or a camera mount for added functionality and fun.
Assemble the 4 Wheel Smart Car Chassis kit
How to assemble the 4 Wheel Smart Car Chassis kit is explained in the post I have presented before. This can be assembled very easily. The link of that article is mentioned below.
Circuit Diagram
The Arduino Bluetooth RC Car Circuit Diagram is not complicated. First, you download the circuit diagram from the download button. It’s more obvious. Small jumpers should be connected to ENA and ENB on the L298N motor driver you are using. It is connected by default when you buy it. Use two or three 3.7V 18659 li-ion batteries to provide power. It cannot use 9V battery. If a 9V battery is used, only the front light, rear light, and horn will work. Gear motor not working. The reason for that is that the 9V battery does not have enough amperage. Front light, rear light, and horn are optional things of Arduino Bluetooth RC Car. Arduino Bluetooth RC car can be made without front light, back light and horn. No need to modify Arduino code.
Connecting the four-gear motors to the l298N Motor Driver.
In this way, connect the wires of the gear motors to the motor power connectors of the l298N motor driver.
- Connect the two right motor Red wires to the “OUT4” terminals on the L298N motor driver.
- Connect the two right motor Black wires to the “OUT3” terminals on the motor driver.
- Connect the two left motor Black wires to the “OUT2” terminals on the motor driver.
- Connect the two left motor Red wires to the “OUT1” terminals on the motor driver.
If you assembled the 4 Wheel Smart Car Chassis kit in the same way I did, connect the motor wires to the motor drive as mentioned below. If not, the direction of motor operation may change in some cases. It can be fixed by changing the motor connection wires of the motor drive. The two gear motors on the right are connected to OUT3 and OUT4 of the L298N Motor Driver. The two gear motors on the left are connected to OUT2 and OUT1 of the L298N Motor Driver.
Connecting the four inputs of the L298N Motor Driver to the Arduino UNO board.
In this way, connect the digital pins of the Arduino board and the inputs of the L298N motor driver by jumper wires.
- Connect the IN1 pin of the motor driver to digital pin D5 on the Arduino.
- Connect the IN2 pin of the motor driver to digital pin D6 on the Arduino.
- Connect the IN3 pin of the motor driver to digital pin D10 on the Arduino.
- Connect the IN4 pin of the motor driver to digital pin D11 on the Arduino.
The Arduino board is powered by the L298N Motor driver.
- Connect the 5V Out connecter of the motor driver to VIN pin on the Arduino.
- Connect the GND connecter of the motor driver to GND pin on the Arduino.
Connecting the Bluetooth module ( HC-05 or HC-06 ) to the Arduino board
Hc-05 and HC-06 Bluetooth modules can be applied to the Arduino Bluetooth RC Car.
In this way, connect the Arduino board and the Bluetooth module by jumper wires.
- Connect the VIN (power) pin of the Bluetooth module to the 5V pin on the Arduino.
- Connect the GND (ground) pin of the Bluetooth module to the GND pin on the Arduino.
- Connect the TXD pin of the Bluetooth module to RX pin on the Arduino.
- Connect the RXD pin of the Bluetooth module TX pin on the Arduino.
When uploading the code to the Arduino board, the TX and RX wires of the Arduino board that are connected to the Bluetooth Module’s RXD and TXD should be temporarily disconnected. After the code is successfully uploaded, connect the wires again.
Connecting the front light, rear light, and horn to the Arduino board. ( Optional )
Front light, rear light, and horn are optional things of Arduino Bluetooth RC Car. Arduino Bluetooth RC car can be made without front light, back light and horn. No need to modify Arduino code.
I use 1W LED bulbs for the front and rear lights. No resistors are needed to connect these. An active buzzer is used as the horn of the vehicle. It emits a beep.
In this way, connect the front and back lights and the 5V active buzzer to the Arduino board.
- Front light, connect the positive terminal (+) to A0 on the Arduino and the negative terminal (-) to the GND on the Arduino.
- Back light, connect the positive terminal (+) to A2 on the Arduino and the negative terminal (-) to the GND on the Arduino.
- 5V Buzzer, connect the positive terminal (+) to A4 on the Arduino and the negative terminal (-) to the GND on the Arduino.
Connect the Battery Power Connection
Use two 3.7V 18659 li-ion batteries to provide power. Do not use more than two batteries. It cannot use 9V battery. If a 9V battery is used, only the ultrasonic sensor and servo motor will work. Gear motor not working. The reason for that is that the 9V battery does not have enough amperage.
First solder the switch to the battery holder. Solder the red wire of the battery holder to one end of the switch and solder a red wire to the other end of the switch. Stick the switch to the battery holder with the glue gun.
- Connect the Red wire (+) of the battery holder to the 12V In of the L298N Motor Driver.
- Connect the Black wire (-) of the battery holder to the GND In of the L298N Motor Driver.
Upload the Arduino Sketch
- Before uploading the code, disconnect the RX and TX pins of the HC-05 Bluetooth module.
- After uploading the code, connect them again
Arduino Bluetooth RC car can be made without front light, backlight and horn. No need to modify Arduino code. Copy the following Arduino code and paste it into the new sketch in the Arduino IDE. Select the board and port and upload the code. If this is difficult to do, watch a tutorial video.
You can download the Arduino code and open it directly through the Arduino IDE. Click the Download button below to download the Arduino code
#define in1 5 //L298n Motor Driver pins.
#define in2 6
#define in3 10
#define in4 11
#define light_FR 14 //LED Front Right pin A0 for Arduino Uno
#define light_FL 15 //LED Front Left pin A1 for Arduino Uno
#define light_BR 16 //LED Back Right pin A2 for Arduino Uno
#define light_BL 17 //LED Back Left pin A3 for Arduino Uno
#define horn_Buzz 18 //Horn Buzzer pin A4 for Arduino Uno
int command; //Int to store app command state.
int Speed = 204; // 0 - 255.
int Speedsec;
int buttonState = 0;
int lastButtonState = 0;
int Turnradius = 0; //Set the radius of a turn, 0 - 255 Note:the robot will malfunction if this is higher than int Speed.
int brakeTime = 45;
int brkonoff = 1; //1 for the electronic braking system, 0 for normal.
boolean lightFront = false;
boolean lightBack = false;
boolean horn = false;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(light_FR, OUTPUT);
pinMode(light_FL, OUTPUT);
pinMode(light_BR, OUTPUT);
pinMode(light_BL, OUTPUT);
pinMode(horn_Buzz, OUTPUT);
Serial.begin(9600); //Set the baud rate to your Bluetooth module.
}
void loop() {
if (Serial.available() > 0) {
command = Serial.read();
Stop(); //Initialize with motors stoped.
if (lightFront) {digitalWrite(light_FR, HIGH); digitalWrite(light_FL, HIGH);}
if (!lightFront) {digitalWrite(light_FR, LOW); digitalWrite(light_FL, LOW);}
if (lightBack) {digitalWrite(light_BR, HIGH); digitalWrite(light_BL, HIGH);}
if (!lightBack) {digitalWrite(light_BR, LOW); digitalWrite(light_BL, LOW);}
if (horn) {digitalWrite(horn_Buzz, HIGH);}
if (!horn) {digitalWrite(horn_Buzz, LOW);}
switch (command) {
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
case 'G':
forwardleft();
break;
case 'I':
forwardright();
break;
case 'H':
backleft();
break;
case 'J':
backright();
break;
case '0':
Speed = 100;
break;
case '1':
Speed = 140;
break;
case '2':
Speed = 153;
break;
case '3':
Speed = 165;
break;
case '4':
Speed = 178;
break;
case '5':
Speed = 191;
break;
case '6':
Speed = 204;
break;
case '7':
Speed = 216;
break;
case '8':
Speed = 229;
break;
case '9':
Speed = 242;
break;
case 'q':
Speed = 255;
break;
case 'W':lightFront = true;break;
case 'w':lightFront = false;break;
case 'U':lightBack = true;break;
case 'u':lightBack = false;break;
case 'V':horn = true;break;
case 'v':horn = false;break;
}
Speedsec = Turnradius;
if (brkonoff == 1) {
brakeOn();
} else {
brakeOff();
}
}
}
void forward() {
analogWrite(in1, Speed);
analogWrite(in3, Speed);
}
void back() {
analogWrite(in2, Speed);
analogWrite(in4, Speed);
}
void left() {
analogWrite(in3, Speed);
analogWrite(in2, Speed);
}
void right() {
analogWrite(in4, Speed);
analogWrite(in1, Speed);
}
void forwardleft() {
analogWrite(in1, Speedsec);
analogWrite(in3, Speed);
}
void forwardright() {
analogWrite(in1, Speed);
analogWrite(in3, Speedsec);
}
void backright() {
analogWrite(in2, Speed);
analogWrite(in4, Speedsec);
}
void backleft() {
analogWrite(in2, Speedsec);
analogWrite(in4, Speed);
}
void Stop() {
analogWrite(in1, 0);
analogWrite(in2, 0);
analogWrite(in3, 0);
analogWrite(in4, 0);
}
void brakeOn() {
//Here's the future use: an electronic braking system!
// read the pushbutton input pin:
buttonState = command;
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == 'S') {
if (lastButtonState != buttonState) {
digitalWrite(in1, HIGH);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, HIGH);
delay(brakeTime);
Stop();
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
}
}
void brakeOff() {
}
Code language: Arduino (arduino)
This code allows the Arduino to receive commands from the Bluetooth module and control the motors, lights, and buzzer accordingly.
How To Download Bluetooth Rc Car App And Its Function
To operate your robot car wirelessly, begin by pairing your mobile device with the HC-05 Bluetooth module and launching the Bluetooth RC Control app. Connect to the module within the app, enabling seamless wireless communication. Once connected, you can utilize the app’s interface to send commands to your robot car, allowing you to observe its movements, turns, and activate features such as lights and the buzzer.
Mobile App Link : https://play.google.com/store/apps/de…
- If the above link does not work, download the app from this Button
Conclusion
This project successfully demonstrates the implementation of a Bluetooth-controlled car using Arduino and a mobile app. The integration of hardware components and software development showcases a practical application of wireless communication for remote control purposes. The project serves as a foundation for further exploration into robotics, IoT, and mobile app development.