Projects / Voice-controlled robot car

Voice-controlled robot car

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. UNO

    Pair the HC-05

    With the phone.

  2. UNO

    Echo the text

    Show the words on the Uno.

  3. UNO

    Add the L298N

    Test each direction.

  4. UNO

    Map the words

    Forward, back, left, right, stop.

  5. UNO

    Add the auto stop

    2 seconds.

  6. UNO

    Test on the table

    Wheels off the ground.

  7. UNO

    Drive on the floor

    In a clear space.

In short

How do you build a voice-controlled robot car?

Speak 'forward', 'left' or 'stop' into a phone app that sends words over Bluetooth to an HC-05 on the car. You need Arduino Uno R3, HC-05 Bluetooth Module, L298N Dual H-Bridge Module, Robot car chassis kit 4WD, Battery holder 18650 2S (series), 18650 cell 2600 mAh (branded) × 2, Resistor 1 kΩ and Resistor 2.2 kΩ. It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
8

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
HC-05 TXDUno D2Phone to Uno
Uno D31 k resistor to HC-05 RXD, with 2.2 k from RXD to GNDVoltage divider (the HC-05 input is 3.3 V)
HC-05 VCC and GNDUno 5V and GNDPower
L298N IN1, IN2, IN3, IN4Uno D7, D8, D9, D10Directions
L298N ENA and ENBUno D5 and D6Speed (remove the jumpers)
L298N OUT1 and OUT2Left wheel motors, wired togetherLeft side
L298N OUT3 and OUT4Right wheel motors, wired togetherRight side
2 x 18650 holderL298N 12V and Uno VINAbout 7.4 V
L298N GNDUno GNDCommon ground

Code

The phone does the hard part, turning your voice into text. The car only needs to read a line of letters, compare it with a few words and move: forward, back, left, right or stop. The sketch collects characters until the end of the line and then looks for the word inside it, so an app that adds extra words still works. Because voice recognition makes mistakes and radio links drop, the car stops by itself two seconds after the last command, so a missed word or a lost connection never leaves it running away. The HC-05's input pin is 3.3 V, so the car's signal goes through a two-resistor divider, while the signal from the HC-05 to the Uno needs no change. Test on a table with the wheels off the ground, then on the floor in a clear space, in a quiet room. Keep the 18650 cells in a proper holder and keep fingers away from the wheels. Arduino IDE, board "Arduino Uno".

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Voice-controlled car: a phone app sends words over Bluetooth, the car obeys. Board: Arduino Uno.
// Use any Android Bluetooth voice-command app that sends the spoken word as text ending with a newline.
// The HC-05 starts at 9600 baud in data mode. Pair it with the phone first.
#include <SoftwareSerial.h>
SoftwareSerial bt(2, 3);                    // RX, TX
const byte IN1 = 7, IN2 = 8, IN3 = 9, IN4 = 10, ENA = 5, ENB = 6;
const int SPEED = 170;
String line = "";
unsigned long lastCmd = 0;
void drive(int l, int r) {
  digitalWrite(IN1, l > 0); digitalWrite(IN2, l < 0); analogWrite(ENA, abs(l));
  digitalWrite(IN3, r > 0); digitalWrite(IN4, r < 0); analogWrite(ENB, abs(r));
}
void setup() {
  bt.begin(9600);
  for (byte p = 5; p <= 10; p++) pinMode(p, OUTPUT);
  drive(0, 0);
}
void act(String w) {
  w.trim(); w.toLowerCase();
  if (w.indexOf("forward") >= 0 || w.indexOf("go") == 0) drive(SPEED, SPEED);
  else if (w.indexOf("back") >= 0 || w.indexOf("reverse") >= 0) drive(-SPEED, -SPEED);
  else if (w.indexOf("left") >= 0) drive(-SPEED, SPEED);
  else if (w.indexOf("right") >= 0) drive(SPEED, -SPEED);
  else if (w.indexOf("stop") >= 0) drive(0, 0);
  else return;
  lastCmd = millis();
}
void loop() {
  while (bt.available()) {
    char c = bt.read();
    if (c == '\n' || c == '\r') { if (line.length()) act(line); line = ""; }
    else if (line.length() < 30) line += c;
  }
  if (millis() - lastCmd > 2000) drive(0, 0);        // stop by itself after 2 seconds with no command
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Say forwardCar drives forward
Say stopCar stops
Say nothing for 2 sCar stops by itself
Phone out of rangeCar stops

If it does not work

Nothing arrives

Check the HC-05 wiring and the baud rate.

Wrong direction

Swap the motor wires on that side.

Misses words

Speak clearly in a quiet room.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the voice-controlled robot car?

Arduino Uno R3, HC-05 Bluetooth Module, L298N Dual H-Bridge Module, Robot car chassis kit 4WD, Battery holder 18650 2S (series), 18650 cell 2600 mAh (branded) × 2, Resistor 1 kΩ and Resistor 2.2 kΩ.

How long does the voice-controlled robot car take to build?

About 120 minutes for a intermediate maker, in 7 steps.

How do I know the voice-controlled robot car works?

Say forward: Car drives forward. Say stop: Car stops. Say nothing for 2 s: Car stops by itself.

Nothing arrives: what should I check?

Check the HC-05 wiring and the baud rate.

Wrong direction: what should I check?

Swap the motor wires on that side.

Misses words: what should I check?

Speak clearly in a quiet room.