Build it step by step
0 of 7 donePair the HC-05
With the phone.
Echo the text
Show the words on the Uno.
Add the L298N
Test each direction.
Map the words
Forward, back, left, right, stop.
Add the auto stop
2 seconds.
Test on the table
Wheels off the ground.
Drive on the floor
In a clear space.
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
- Development BoardsBuyArduino Uno R3 × 1
- WirelessBuy
- Motor DriversBuy
- Mechanical & HardwareBuy
- PowerBuy
- BatteriesBuy
- PassivesBuyResistor 1 kΩ × 1
- PassivesBuyResistor 2.2 kΩ × 1
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| HC-05 TXD | Uno D2 | Phone to Uno |
| Uno D3 | 1 k resistor to HC-05 RXD, with 2.2 k from RXD to GND | Voltage divider (the HC-05 input is 3.3 V) |
| HC-05 VCC and GND | Uno 5V and GND | Power |
| L298N IN1, IN2, IN3, IN4 | Uno D7, D8, D9, D10 | Directions |
| L298N ENA and ENB | Uno D5 and D6 | Speed (remove the jumpers) |
| L298N OUT1 and OUT2 | Left wheel motors, wired together | Left side |
| L298N OUT3 and OUT4 | Right wheel motors, wired together | Right side |
| 2 x 18650 holder | L298N 12V and Uno VIN | About 7.4 V |
| L298N GND | Uno GND | Common 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.
| Check | Expected |
|---|---|
| Say forward | Car drives forward |
| Say stop | Car stops |
| Say nothing for 2 s | Car stops by itself |
| Phone out of range | Car 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 →
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.
