TechForLive
Robotics & DIY Electronics

Bluetooth car with Arduino and HC-05: a first build that drives

Wire an HC-05 to an Arduino Uno, drive two motors through an L298N, and steer the car from your phone with one-letter commands.

Small robot car with Arduino Uno, HC-05 Bluetooth module and L298N driver board

Some links in this guide are affiliate links: if you buy, TechForLive may earn a commission at no extra cost to you. Details.

In short: A Bluetooth controlled car with Arduino and HC-05 links your phone to a small robot car. The HC-05 passes one-letter drive commands to an Arduino Uno. The Uno tells an L298N driver board how fast each wheel turns, and in which direction. You build it with a few common parts and one sketch.
  • Wire the HC-05 RX pin through a 1k and 2k resistor divider, or 5V will reach a 3.3V pin.
  • Give the motors their own battery and join the grounds, or the Arduino resets when the wheels start.
  • Use single letters for commands: F, B, L, R and S keep the phone app and the sketch simple.
  • Pair with PIN 1234 first; some modules ship with 0000 instead.

How a Bluetooth controlled car with Arduino and HC-05 works

Your phone sends a single letter over Bluetooth each time you tap a button. That letter reaches the HC-05 module, which hands it to the Arduino over a serial link. From there the Arduino sets the motor driver pins for forward, back, left, right or stop. Nothing here needs the internet. It is a short radio hop between two boards on the same desk.

Three boards do three jobs. One board handles the radio link: the HC-05 speaks serial, which is a stream of bytes over two wires. Your sketch runs on the Arduino Uno, which decides what each letter means. Real motor current comes from the L298N driver board, which switches far more than Arduino pins can supply on their own. Each board is cheap and easy to replace. That split keeps the build simple to test in stages.

Steering works by driving the two wheels at different speeds. Forward means both wheels turn the same way. A left turn slows or stops the left wheel while the right wheel keeps turning. It pivots around the slow wheel. This is called differential drive, and it needs no steering servo. Two motors and one driver board are the whole steering system.

At a glanceAnswer
HC-05 data baud9600 baud
HC-05 AT-mode baud38400 baud
HC-05 logic level3.3 V
Divider resistors1k and 2k ohms
Bluetooth rangea few metres indoors
Drive commandsF, B, L, R, S
Free toolBattery Life CalculatorRuntime from mAh, and real power-bank charges.Open →

The parts and the wiring map

You need an Arduino Uno, an HC-05 Bluetooth module and an L298N driver board. Add two small DC gear motors with wheels, a chassis or a stiff board, jumper wires, a battery pack and two resistors. Most sellers bundle the motors, wheels and chassis as one robot car kit. Buy the kit if you can. It saves a fiddly afternoon of drilling and gluing.

Batteries matter more than most first builds admit. A single 9V block looks tidy, but it sags the moment both motors start and the Arduino may reset. Six AA cells in a holder give far more current and last longer. Two rechargeable 18650 cells in a holder work too, at about 7.4V. Handle 18650 cells with care: use a proper holder and a charger made for them, and never short the ends. Pick one pack and use it only for the motors. While you test, the Arduino runs from USB, then from its own supply later.

Hold the wiring map in front of you while you connect things. Here the HC-05 talks to Arduino pins 10 and 11 through a software serial port. Six Arduino pins go to the L298N: two enable pins for speed and four direction pins. Motor power comes from the battery, which feeds the L298N motor terminals, never the Arduino 5V pin. That table is the whole map, so check each wire against it before you switch anything on.

Arduino pinConnects toNote
10HC-05 TXDArduino receives data
11HC-05 RXDthrough the 1k and 2k divider
5 (PWM)L298N ENAleft motor speed
6 (PWM)L298N ENBright motor speed
7L298N IN1left motor direction
8L298N IN2left motor direction
4L298N IN3right motor direction
2L298N IN4right motor direction
GNDL298N GND and battery minuscommon ground
5VHC-05 VCCmodule power

Wire the HC-05 so 5V never reaches its RX pin

HC-05 module wired to Arduino with two resistors on a breadboard

Inside the HC-05, everything runs on 3.3V logic. Its VCC pin accepts 5V from the Arduino, because most breakout boards carry their own regulator. Its RX pin does not. Arduino TX sends 5V, and feeding that straight into the HC-05 RX pin can damage the module over time. A voltage divider made from two resistors fixes it. It costs cents and takes a minute.

Join a 1k resistor between Arduino pin 11 and the HC-05 RX pin. Join a 2k resistor between the HC-05 RX pin and ground. Standard quarter-watt resistors are fine for this divider. Together they split the 5V, and the HC-05 RX pin sees about 3.3V. That is the divider the Arduino forum and module guides recommend. No divider is needed on the HC-05 TX pin, because its 3.3V output still reads as HIGH on a 5V Arduino input. Connect it straight to Arduino pin 10.

Power the module from the Arduino 5V pin and ground. HC-05 modules use an LED to show status. Typical patterns are a fast blink when discoverable and unpaired, and a steadier or slower blink when paired or in certain modes. Exact patterns vary by module, so check the datasheet or vendor notes for your board. Check the LED before you blame the code. If the LED never lights, check VCC and ground first. If it blinks but the phone cannot see it, the module may already be paired to another phone.

Warning: Never connect the Arduino TX pin straight to the HC-05 RX pin. The 5V signal can damage a 3.3V input, and the failure shows up weeks later as a dead module.

Wire the L298N and give the motors their own battery

Between the Arduino and the motors sits the L298N. It takes small 5V logic signals from the Arduino and switches the bigger motor current from the battery. One board drives both wheels, because it holds two H-bridges, one per motor. An H-bridge is a set of switches that flips which way current flows through a motor. Flip the switches one way and the wheel turns forward. Flip them the other way and it turns back.

Connect the battery plus lead to the L298N terminal marked 12V and the minus lead to GND. Connect the Arduino GND pin to the same L298N GND terminal. This shared ground is the wire most first builds forget, and without it the direction signals mean nothing to the driver board. Without it, the motors behave at random or sit still. Check that wire before you test anything else.

Each motor connects across one output pair: OUT1 and OUT2 for the left motor, OUT3 and OUT4 for the right. Remove the small jumper caps on ENA and ENB if you want speed control, then wire those pins to Arduino PWM pins 5 and 6. Leave the 5V-enable jumper in place when your motor battery is 12V or less, so the board makes its own 5V for the logic side. Inside the chip, the L298N drops about 2V, so a 7.4V pack gives the motors roughly 5V. That is normal for this board. Most L298N boards already carry flyback diodes, so you usually add none for the motors.

Common mistake: Never power the motors from the Arduino 5V pin. The motors pull far more current than the pin can give, and the board will reset or brown out.

The sketch that turns letters into motion

Arduino IDE on a laptop screen showing robot car code

Keep the sketch short on purpose. It opens a software serial port on pins 10 and 11 for the HC-05, so the USB serial port stays free for the Serial Monitor. It sets the six L298N pins as outputs. Then it loops, reading one letter at a time from the Bluetooth link. Each letter runs a small function: forward, back, left, right or stop. Copy the sketch below as shown: it is complete and it compiles.

Speed comes from analogWrite on the enable pins, with 0 for stopped and 255 for full speed. A value of 200 keeps it brisk without being wild on a desk. Lower it to 150 if the car jumps when it starts. Direction comes from the IN pins: one HIGH and one LOW turns a motor one way, and the pair reversed turns it the other way. Both LOW stops that motor. A left turn stops the left motor and runs the right one, so the car pivots.

Upload the sketch over USB as normal. Pins 10 and 11 carry the HC-05 link, so it never fights the USB upload on pins 0 and 1. Open the Serial Monitor at 9600 baud and type F, then press send. It should roll forward. If nothing moves, check the wiring table again before you change the code. Most first failures are a wire, not a sketch.

Bluetooth car sketch for Arduino Uno

#include <SoftwareSerial.h>
SoftwareSerial bt(10, 11); // RX, TX

const int ENA = 5, IN1 = 7, IN2 = 8;   // left motor
const int ENB = 6, IN3 = 4, IN4 = 2;   // right motor
const int SPEED = 200;

void setup() {
  pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  bt.begin(9600);
}

void loop() {
  if (bt.available()) {
    char c = bt.read();
    if (c == 'F') drive(1, 1);
    else if (c == 'B') drive(-1, -1);
    else if (c == 'L') drive(0, 1);
    else if (c == 'R') drive(1, 0);
    else if (c == 'S') drive(0, 0);
  }
}

void drive(int left, int right) {
  setMotor(ENA, IN1, IN2, left);
  setMotor(ENB, IN3, IN4, right);
}

void setMotor(int en, int in1, int in2, int dir) {
  if (dir > 0) { digitalWrite(in1, HIGH); digitalWrite(in2, LOW); }
  else if (dir < 0) { digitalWrite(in1, LOW); digitalWrite(in2, HIGH); }
  else { digitalWrite(in1, LOW); digitalWrite(in2, LOW); }
  analogWrite(en, dir == 0 ? 0 : SPEED);
}

Drive it from your phone and fix what fails

Pair the phone to the HC-05 from the phone Bluetooth settings, not from inside the app. It shows up as HC-05, and the PIN is usually 1234. Some modules ship with 0000, so try that next if 1234 fails. Open a Bluetooth RC car app once the phone says paired. Apps such as Arduino Bluetooth RC Car send one letter per button press, which is exactly what the sketch expects. Tap the forward arrow and the car should roll.

A car that spins in place has one motor wired backwards. Swap the two wires on one motor at the L298N terminals and test again. Crawling points to a tired battery pack, so fit a fresh one. No response to the phone means the HC-05 TX and RX lines may be crossed. TXD goes to Arduino pin 10 and RXD goes to pin 11 through the divider. Swap them only if the module never answers.

Range is the last limit to accept. Typical indoor usable range for the HC-05, a Bluetooth Classic class 2 module, is a few metres to a dozen metres. Walls and interference reduce that. Walk to the next room and the car will lag or stop. That is normal for this module, not a fault in your build. Keep the phone in the same room as the car. If you need more range, test your own module or choose a different radio.

Quick answers

Can I use an HC-06 instead of an HC-05?

Yes, for this build. As a slave-only module, the HC-06 still works here, because this car only needs to listen. Wiring and sketch stay unchanged. Buy the HC-05 only if you later want the module to start connections itself.

Why does my car reset when the motors start?

At start-up, the motors pull a surge of current, and a weak battery sags below the level the Arduino needs. Give the motors their own fresh pack and join the grounds. Keep the Arduino on USB or its own supply while you test.

Do I need the voltage divider if my HC-05 board has a regulator?

Yes, usually. On most breakout boards, the regulator handles the power pin, not the RX pin. That RX pin still expects 3.3V logic, so keep the 1k and 2k divider in place. A level shifter works too, and it is the tidier option if you plan to reuse the module.

Can I control the car from a laptop instead of a phone?

Yes. Pair the laptop to the HC-05, open a serial terminal at 9600 baud, and type the same letters. It cannot tell a laptop from a phone, because both send the same single letters. A laptop is handy for testing, and the phone is better for driving.

How far will the car drive from my phone?

A few metres to a dozen metres indoors, which is the normal range for a Bluetooth Classic module like the HC-05. Walls and other 2.4 GHz devices cut that down. Drive in the same room, and expect the link to drop if you walk away with the phone.