
Build a Bluetooth Car You Can Control from Your Phone
Build your own Arduino Bluetooth robot car and control it wirelessly using an Android smartphone. In this beginner-friendly tutorial, you will learn how to connect an HC-05 Bluetooth module with an Arduino UNO and L298N motor driver, understand the wiring, upload the Arduino code, and control your car using forward, backward, left, right, and stop commands.
Introduction
Have you ever wanted to control a robot car using your smartphone? With an Arduino UNO, an HC-05 Bluetooth module, and an L298N motor driver, you can build a wireless robot car that responds to commands sent from your phone.
The HC-05 provides a Bluetooth serial connection between your smartphone and Arduino. When you press a direction button in a compatible Bluetooth controller app, the module sends a character to the Arduino. The Arduino reads that character and tells the L298N motor driver how to operate the motors.
This project is a great starting point for students, electronics enthusiasts, and beginners interested in Arduino robotics, wireless communication, and DIY automation.
1. Components Required
You will need the following components to build a basic two-motor Bluetooth robot car:
| Component | Quantity | Purpose |
|---|---|---|
| Arduino UNO | 1 | Main controller |
| HC-05 Bluetooth module | 1 | Wireless phone communication |
| L298N motor driver | 1 | DC motor direction and speed control |
| DC geared motors | 2 | Move the robot car |
| Robot car chassis | 1 | Holds the components |
| Wheels | 2 | Vehicle movement |
| Battery pack | 1 | Motor power |
| Jumper wires | As needed | Electrical connections |
| Android smartphone | 1 | Wireless control |
For a four-wheel chassis, you can use four motors, with two motors on the left and two on the right. Connect each side to one L298N channel only if the combined motor current is within the driver’s safe limits.
2. What Is the HC-05 Bluetooth Module?
The HC-05 is a Bluetooth serial communication module that allows an Arduino to exchange data wirelessly with compatible devices.
It uses Bluetooth Classic and Serial Port Profile (SPP). In this project, the HC-05 receives commands from a smartphone and passes them to the Arduino through serial communication.
Main features:
-
Wireless serial communication.
-
Commonly used with Arduino UNO and other microcontrollers.
-
Can operate as a Bluetooth master or slave.
-
Common breakout boards accept a 5V power supply through their onboard regulator.
-
UART communication uses 3.3V logic levels.
The common data-mode baud rate is 9600, although previously configured modules may use a different setting.
3. HC-05 Pinout
| HC-05 Pin | Function |
|---|---|
| EN / KEY | Used to enter AT command mode |
| VCC | Power input |
| GND | Ground |
| TXD | Sends serial data |
| RXD | Receives serial data |
| STATE | Bluetooth connection status |
Important voltage warning: Many HC-05 breakout boards have an onboard regulator, so their VCC pin can accept 5V. However, the RXD data input is 3.3V logic. Use a voltage divider between Arduino’s 5V TX output and HC-05 RXD to protect the module.
4. L298N Motor Driver Pinout
The L298N motor driver controls the direction and speed of the DC motors.
| L298N Pin | Function |
|---|---|
| ENA | Motor A speed control |
| IN1, IN2 | Motor A direction |
| ENB | Motor B speed control |
| IN3, IN4 | Motor B direction |
| OUT1, OUT2 | Motor A connections |
| OUT3, OUT4 | Motor B connections |
| +12V / Vs | Motor supply input |
| GND | Common ground |
| +5V | Logic supply or regulated output, depending on module configuration |
5. Arduino Bluetooth Car Wiring
The following wiring is for an Arduino UNO, HC-05, L298N, and two DC motors.
A. HC-05 to Arduino UNO
| HC-05 | Arduino UNO |
|---|---|
| VCC | 5V* |
| GND | GND |
| TXD | D2 |
| RXD | D3 through a voltage divider |
| EN / KEY | Not connected |
| STATE | Not connected |
Use 5V on VCC only if your HC-05 is a breakout board with a suitable onboard regulator. A bare HC-05 module requires a regulated 3.3V supply.
Voltage divider for HC-05 RXD:
Connect Arduino D3 to a 1kΩ resistor, then connect the other end of that resistor to HC-05 RXD. Connect a 2kΩ resistor from the HC-05 RXD junction to GND.
B. L298N to Arduino UNO
| L298N | Arduino UNO |
|---|---|
| ENA | D5 |
| IN1 | D8 |
| IN2 | D9 |
| IN3 | D10 |
| IN4 | D11 |
| ENB | D6 |
| GND | GND |
Remove the ENA and ENB jumpers if you want Arduino PWM speed control through D5 and D6.
C. DC Motor Connections
| L298N Output | Motor |
|---|---|
| OUT1 and OUT2 | Left motor |
| OUT3 and OUT4 | Right motor |
If a motor rotates in the opposite direction from the expected movement, swap its two output wires or reverse its direction logic in the code.
D. Power Supply Connections
-
Connect the battery positive wire to the L298N motor supply terminal.
-
Connect the battery negative wire to L298N GND.
-
Connect Arduino GND to L298N GND.
-
Power the Arduino through USB during testing or use a suitable regulated supply.
-
Power the HC-05 from the Arduino 5V pin only if it is a regulator-equipped breakout board.
Safety precautions:
-
Never connect the motor battery positive wire to the Arduino 5V pin.
-
Do not power motors directly from the Arduino.
-
All grounds must be connected together.
-
Use a battery pack, protection circuit, and charger suitable for the battery chemistry and motor voltage.
-
Check motor stall current before connecting two motors in parallel to one L298N channel.
6. How Does the Bluetooth Car Work?
The working process is simple:
-
Pair your smartphone with the HC-05 Bluetooth module.
-
Open a compatible Bluetooth RC car controller app.
-
Connect to the HC-05 device.
-
Press a direction button on your phone.
-
The app sends a character to the HC-05.
-
The HC-05 transfers that character to the Arduino.
-
The Arduino processes the command and controls the L298N motor driver.
-
The motors rotate to move the car.
Bluetooth command table
| Phone command | Car movement |
|---|---|
| F | Forward |
| B | Backward |
| L | Left |
| R | Right |
| S | Stop |
Choose an Android Bluetooth controller app that lets you assign these characters to its buttons. The app must send uppercase characters matching the Arduino code.
7. Arduino Code for Bluetooth-Controlled Car
This program uses the Arduino UNO, HC-05 Bluetooth module, and L298N motor driver. It supports forward, backward, left, right, and stop commands.
#include <SoftwareSerial.h>
// HC-05 Bluetooth connection
// Arduino D2 = RX, Arduino D3 = TX
SoftwareSerial BT(2, 3);
// L298N Motor Driver Pins
const int ENA = 5;
const int IN1 = 8;
const int IN2 = 9;
const int ENB = 6;
const int IN3 = 10;
const int IN4 = 11;
// Motor speed: 0 to 255
int motorSpeed = 180;
// Safety timeout
unsigned long lastCommandTime = 0;
const unsigned long commandTimeout = 1200;
void setup() {
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
BT.begin(9600);
stopCar();
}
void loop() {
if (BT.available()) {
char command = BT.read();
lastCommandTime = millis();
switch (command) {
case 'F':
forward();
break;
case 'B':
backward();
break;
case 'L':
turnLeft();
break;
case 'R':
turnRight();
break;
case 'S':
stopCar();
break;
default:
// Ignore unknown characters
break;
}
}
// Stop if Bluetooth commands stop arriving
if (millis() - lastCommandTime > commandTimeout) {
stopCar();
}
}
// Move forward
void forward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
analogWrite(ENA, motorSpeed);
analogWrite(ENB, motorSpeed);
}
// Move backward
void backward() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENA, motorSpeed);
analogWrite(ENB, motorSpeed);
}
// Turn left
void turnLeft() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
analogWrite(ENA, motorSpeed);
analogWrite(ENB, motorSpeed);
}
// Turn right
void turnRight() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENA, motorSpeed);
analogWrite(ENB, motorSpeed);
}
// Stop both motors
void stopCar() {
analogWrite(ENA, 0);
analogWrite(ENB, 0);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
Important code note: The timeout stops the car if it stops receiving commands for 1.2 seconds. Choose an app that repeatedly sends the movement character while a direction button is held and sends S when released. This helps prevent the car from continuing to move if the Bluetooth connection is interrupted.
8. How to Control the Car Using Your Phone
Follow these steps:
-
Upload the Arduino code to your UNO.
-
Turn on the HC-05 module.
-
Enable Bluetooth on your Android smartphone.
-
Search for available Bluetooth devices.
-
Select HC-05.
-
Enter the pairing PIN, commonly
1234or0000, if requested. -
Open a compatible Bluetooth RC car controller app.
-
Connect to HC-05 from inside the app.
-
Press the direction buttons to control your robot car.
Compatibility note: Generic HC-05 modules use Bluetooth Classic SPP. They are commonly used with Android Bluetooth serial apps. Standard iPhone apps generally cannot communicate with generic HC-05 modules through SPP, so an iOS-compatible BLE solution may be required.
9. How to Test Your Bluetooth Car
Test the car with its wheels lifted off the ground before placing it on the floor.
| Test | Button | Expected Result |
|---|---|---|
| Forward | F | Both sides rotate forward |
| Backward | B | Both sides rotate backward |
| Left | L | Car pivots left |
| Right | R | Car pivots right |
| Stop | S | Both motors stop |
If the car moves in the wrong direction, check the motor output wiring and the direction logic in the code.
10. Common Problems and Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| HC-05 does not appear | Module has no power | Check VCC and GND |
| Phone cannot connect | Incorrect pairing PIN | Try the module’s configured PIN |
| Bluetooth connects but car does not move | Incorrect TX/RX wiring | Check crossed serial connections |
| Car moves in reverse | Motor wires reversed | Swap the motor output wires |
| Only one side moves | Loose motor connection | Check L298N output terminals |
| Arduino resets | Battery voltage drops under load | Use a suitable motor supply |
| HC-05 stops communicating | Incorrect baud rate | Check module data-mode baud rate |
| Motor driver overheats | Excessive motor current | Reduce load or use a suitable higher-current driver |
11. Improvements You Can Add to Your Bluetooth Car
Once the basic Bluetooth car works, you can expand it with additional components and features.
Ultrasonic obstacle detection: Add an HC-SR04 sensor to detect objects in front of the car.
Automatic obstacle avoidance: Add a separate autonomous driving mode so the car can avoid obstacles without phone commands.
LED headlights: Add LEDs for front headlights and rear indicators.
Servo motor: Mount an ultrasonic sensor on a servo to scan different directions.
Four-wheel drive: Use four DC geared motors, with the two left motors connected to one motor-driver channel and the two right motors connected to the other, provided the combined current is safe for the driver.
Explore more Arduino boards and electronics components through the Electroway Arduino category. You can also visit Electroway.org and explore the Electroway app for components used in robotics projects.
Frequently Asked Questions (FAQs)
1. Can I control an Arduino car using my Android phone?
Yes. An HC-05 Bluetooth module allows an Arduino robot car to receive wireless serial commands from a compatible Android Bluetooth controller app.
2. What is the difference between HC-05 and HC-06?
Both modules provide Bluetooth serial communication. The HC-05 can be configured as either a master or slave, while the common HC-06 module is designed for slave operation.
3. Can I use four motors with an L298N?
Yes, in some small robot-car designs, two motors can be connected in parallel to each motor-driver channel. However, the combined current must remain within the driver’s safe operating limits. Check the stall current of each motor.
4. Does the HC-05 need a separate battery?
Usually not. A common regulator-equipped HC-05 breakout board can receive power from the Arduino 5V output, provided the supply is suitable. Its RXD data input still needs 3.3V logic.
5. What is the usual Bluetooth range of HC-05?
Many HC-05 setups are used over approximately 10 metres in open conditions. Actual range depends on the module, antenna, interference, and surroundings.
6. Can I use an ultrasonic sensor with a Bluetooth car?
Yes. You can add an HC-SR04 ultrasonic sensor to measure distance and implement obstacle detection or automatic driving modes.
7. Why does my Bluetooth car stop after a short time?
This tutorial includes a safety timeout. The controller app must keep sending movement commands while a direction button is held. If it sends only one character, the car will stop after the timeout.
