TechForLive
Robotics & DIY Electronics

HC-05 car control: Arduino pins and phone commands

Build a bluetooth controlled car with Arduino and HC-05: exact pins, divider, L298N wiring, phone commands and a safe first test.

Arduino Uno board wired to a small sensor module with USB cable

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 needs crossed serial wires. It also needs a divider on the module receive line. An L298N sits between board and motors, and your phone sends single letters to steer.
  • Cross the serial lines every time: module transmit goes to board receive, never transmit to transmit.
  • Treat pins 0 and 1 as shared with USB uploads, so expect to unplug a wire while you upload.
  • Give the motors their own supply and join the grounds, or the board will reset under load.
  • Add a stop letter and use it on release, or the car keeps its last order until it hits something.

Pins first: how the module talks to your board

Your bluetooth controlled car with Arduino and HC-05 lives or dies on four wires. Get those right and the rest is code. Get one crossed and the phone pairs happily while nothing moves.

Most HC-05 breakout boards accept 3.6 to 6 V on VCC and regulate it down inside. Underneath, the bare module runs on 3.3 V logic. Feed the breakout from the Arduino 5V pin and join both grounds together.

Serial data needs a cross. Module TXD goes to Arduino pin 0, the receive pin. Arduino pin 1, the transmit pin, goes back to module RXD. TX talks. RX listens. Two talkers on one wire hear nothing.

That return wire needs a voltage divider. An Uno sends 5 V logic, while RXD expects 3.3 V logic. A 1 kΩ resistor from pin 1 and a 2 kΩ resistor to ground drop the signal safely.

Leave EN and STATE unconnected for normal driving. EN only matters for AT mode, the setup mode for changing the name, code or speed.

Pins 0 and 1 also carry USB uploads on an Uno. Leave a module wired there and new sketches can fail. Unplug the wire on pin 0 while you upload, then reconnect it to drive.

  • Label check: boards print RXD and TXD or plain RX and TX, so match letters, not positions
  • Divider swap: a logic level shifter module does the same job for readers without those resistor values
  • AT mode entry: hold EN high while power is applied, then talk at 38400 baud
  • Bench parts: Uno, HC-05 breakout, jumper wires and the two divider resistors
HC-05 to Arduino wiring list
Module pinArduino sideNote
VCC5V pinBreakout supply input
GNDGND pinShared ground
TXDPin 0 (RX)Module talks, board listens
RXDPin 1 (TX)Through the divider
EN, STATENot connectedDriving needs neither
Warning: Do not feed 5 V straight into RXD. The divider looks optional until the module stops answering.
At a glanceAnswer
Module supply3.6 to 6 V on breakout
Serial pins0 receive, 1 transmit
Data speed9600 baud default
Driver rating46 V, 2 A per channel
Pairing code1234 on most boards
Drive lettersF B L R plus S stop
Free toolLED Resistor & Ohm's Law CalculatorRight resistor for LEDs and sensors.Open →

Motors need a driver between them and the board

L298N driver board with heatsink close up

An Arduino pin cannot run a motor. Motors pull far more current than a logic pin can give. An L298N sits in the middle and handles the heavy switching for you.

Inside sits a dual H-bridge, two switch sets that can reverse current through a motor. STMicroelectronics rates the L298 chip for an operating supply up to 46 V and 2 A DC per channel. Your module board sets lower practical limits, so follow the markings printed beside its terminals.

Wire the left motor across OUT1 and OUT2. Put the right motor across OUT3 and OUT4. Four inputs, IN1 to IN4, tell each bridge which way to push. Enable pins ENA and ENB decide whether each side runs at all.

Keep both enable jumpers fitted for full-speed driving. Pull a jumper only for speed control from a PWM pin. PWM means rapid on-off pulses averaging to a lower speed.

Size the motor supply from the motor datasheet, not from hope. Find the stall current, the draw when the shaft cannot turn. Compare that figure with the driver limit and the supply rating, and leave clear headroom above it.

Run the motors from a separate supply matched to their rated voltage. Never run them from the Arduino 5V pin. Join the two grounds together so the control signals still make sense.

  • Sketch pins here: IN1 on 7, IN2 on 8, IN3 on 9, IN4 on 10
  • Pack example: four AA cells suit many small motors, after you check the motor rating
  • Board power: USB power bank on the bench, barrel jack supply inside Arduino's stated range for driving
  • Wire order: join grounds first, then motor leads, then logic inputs last

Letters from your phone become wheel moves

Sketch code, the program you upload to the board, does one job in a loop. It waits for a character, reads it, and sets the four direction inputs. Simple beats clever here. You can debug a letter. You cannot debug a mystery packet.

Use 9600 baud in Serial.begin(), matching the module in data mode. Read with Serial.available() first, then take one character with Serial.read(). Echo it back with Serial.println() while you build, so you can see what arrived.

Five letters cover a small car well. Each letter sets the four inputs to one fixed pattern in the sketch below. Treat S as your stop letter from the start, not as an afterthought.

Map phone buttons to those letters instead of typing while you drive. Set the app to send plain ASCII text, one character per tap. Send S when your finger lifts, so the car stops with you.

This example puts the direction inputs on pins 7, 8, 9 and 10. Change the four numbers at the top if your wiring differs. Keep the letter meanings the same in the app and the sketch, or left becomes right at speed.

Bluetooth car sketch for Uno and L298N

const int IN1 = 7;
const int IN2 = 8;
const int IN3 = 9;
const int IN4 = 10;

void setMotors(int a1, int a2, int b1, int b2) {
  digitalWrite(IN1, a1);
  digitalWrite(IN2, a2);
  digitalWrite(IN3, b1);
  digitalWrite(IN4, b2);
}

void setup() {
  Serial.begin(9600);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  setMotors(LOW, LOW, LOW, LOW);
}

void loop() {
  if (!Serial.available()) return;
  char cmd = Serial.read();
  Serial.println(cmd);
  if (cmd == 'F') setMotors(HIGH, LOW, HIGH, LOW);
  else if (cmd == 'B') setMotors(LOW, HIGH, LOW, HIGH);
  else if (cmd == 'L') setMotors(LOW, HIGH, HIGH, LOW);
  else if (cmd == 'R') setMotors(HIGH, LOW, LOW, HIGH);
  else setMotors(LOW, LOW, LOW, LOW);
}

Build in stages and faults stay small. Prove the wireless link on its own first, with the driver still off the bench. A letter that arrives cleanly on screen cannot be a motor fault later.

Upload the sketch with the pin 0 wire lifted, then reconnect the module. Open the Serial Monitor at 9600 baud. Pair the phone from its Bluetooth settings and pick the device named HC-05.

1234 is the HC-05 default. If it fails, check you paired with HC-05 and not an HC-06, which may use 0000 or 1234. Then open a Bluetooth serial terminal app and connect to the same device.

Send F, B, L, R and S one at a time. Each letter should echo in the monitor exactly as sent. Wrong characters point to a speed mismatch. Silence points to wiring. Fix it now, while the car cannot run away.

Only then power down and add the driver, motors and motor supply. Recheck every terminal against your wiring list before power returns. Raise the wheels on a stand for the first powered run, so a reversed wire spins air, not furniture.

Stay close for that first run. Walls and bodies cut Bluetooth range fast, and a dropout looks exactly like a wiring fault. Lower the car once every letter moves the right wheels the right way.

  1. Upload the sketch, then reconnect the module wires.
  2. Pair the phone with HC-05 using code 1234.
  3. Connect from a Bluetooth serial terminal app.
  4. Send each drive letter and watch the echo.
  5. Power down, wire the driver, and recheck terminals.
  6. Run the raised-wheel check before floor driving.
Rule of thumb: Raise the wheels for the first powered run, so a wiring error spins air instead of sending the car across the bench.

When pairing fails or a wheel goes backwards

Faults here follow clear patterns once you know them. Work from power to wires to code, in that order. Random part swapping wastes an evening and teaches you nothing.

No pairing at all usually means no power or too much distance. Check VCC and ground with the board powered. Move the phone beside the module and try again. Confirm you picked HC-05, not a neighbour's device.

Pairing that succeeds with no data means the serial cross is wrong. Module transmit must land on board receive. Check the divider sits on the board-to-module wire, not the other way round. Confirm 9600 baud at both ends.

Errors during upload with the module attached are normal on pins 0 and 1. Those pins serve USB and the module at once. Lift the pin 0 wire, upload, and reconnect. A software serial library on other pins avoids the clash, at some cost in reliability.

One wheel running backwards needs one change, not three. Reverse that motor's pair of leads, or invert its two inputs in code. Pick one fix and test again. Changing both puts you back where you started.

Resets, jitter or a hot driver mean the power side is struggling. Confirm the motors run from their own supply with a shared ground. Stop the run and let everything cool before you touch the wiring again.

Your bluetooth controlled car with Arduino and HC-05, end to end

Finished small robot car on floor

Lay the parts out before any wire goes in. You need an Uno, an HC-05 breakout and an L298N module. Add two small DC motors, a chassis with wheels, a battery holder, jumper wires and the two divider resistors.

Assembly runs in a fixed order. Motors and driver mount on the chassis first, then the board and module go on top. Grounds join before supplies connect, and the sketch uploads last, with the pin 0 wire lifted.

A common belief says the phone drives the car. It does not. Your phone only sends letters, and the sketch decides what each letter means. Change the sketch and the same app drives a different car.

Another belief says more supply volts always mean more speed. Past the motor rating, extra volts mostly mean heat and wear. Match the supply to the motor datasheet and let the driver stay inside its own limits.

Speed control comes later, when basic driving feels boring. Move ENA and ENB to PWM pins and add letters for slow and fast. Sensors can follow the same way, without touching the wireless link at all.

Short wires and labelled terminals keep faults easy to trace later. Change one thing at a time, test it, and only then move on to the next improvement.

  • Before you decide: confirm your board is a breakout, not a bare module
  • Before you decide: read the stall current in your motor datasheet
  • Before you decide: pick four free digital pins for the driver inputs
  • Before you decide: choose a terminal app that sends single ASCII letters

Quick answers

Can I use pins other than 0 and 1 for the HC-05?

Yes. SoftwareSerial can run the link on other digital pins and leaves USB uploads alone. Hardware serial on pins 0 and 1 stays the steadier choice for a first build.

Why does RXD need a divider if VCC takes 5 V?

Power and logic levels are separate things. Your breakout regulates its supply down inside, but the receive input still expects 3.3 V logic. A divider protects that input from the Uno transmit pin.

What if my motor stall current beats the driver limit?

Pick a different motor or a stronger driver. Running past the per-channel rating overheats the chip and can damage it. Motor and driver datasheets must agree before you wire anything.

Do I need AT mode to drive the car?

No. Data mode at 9600 baud drives the car with factory settings. AT mode only changes settings such as the device name, pairing code or serial speed.

How do I add speed control later?

Remove an enable jumper and wire that enable pin to a PWM output. Then use analogWrite() in the sketch to set the level. Add new letters for slow and fast so the phone controls stay simple.