You will build a robotic car that responds to voice commands via a Bluetooth module (HC-05). The voice commands will be converted to text using a mobile app like “Arduino Voice Control”, then transmitted over Bluetooth to the Arduino, which will control the car’s motion.
Components Required
Component | Quantity |
---|---|
Arduino UNO/Nano | 1 |
L298N Motor Driver | 1 |
HC-05 Bluetooth Module | 1 |
DC Motors (Gear Motors) | 2 (or 4) |
Wheels | 2 (or 4) |
Chassis | 1 |
Battery Pack (6V or 12V) | 1 |
Jumper Wires | As needed |
Wiring Connections
1. L298N Motor Driver to Arduino:
L298N Pins | Arduino Pins |
---|---|
IN1 | 4 |
IN2 | 5 |
IN3 | 6 |
IN4 | 7 |
ENA | 10 (PWM) |
ENB | 11 (PWM) |
- Connect Motor A to OUT1 & OUT2
- Connect Motor B to OUT3 & OUT4
- Connect 12V & GND to Battery
- Connect 5V (from L298N) to Arduino 5V (if jumper is on)
2. HC-05 Bluetooth Module to Arduino:
HC-05 Pins | Arduino Pins |
---|---|
VCC | 5V |
GND | GND |
TXD | RX (Pin A0) |
RXD | TX (Pin A1) |
Voice Commands Expected
You can use an Android app like “Arduino Bluetooth Control” or “BT Voice Control for Arduino”.
Commands to send via voice (converted to text over Bluetooth):
forward
backward
left
right
stop
Arduino Code
#include <SoftwareSerial.h>
// Motor Pins
const int IN1 = 4;
const int IN2 = 5;
const int IN3 = 6;
const int IN4 = 7;
const int ENA = 10;
const int ENB = 11;
// SoftwareSerial for Bluetooth on A0 (RX) and A1 (TX)
SoftwareSerial BTSerial(A0, A1); // RX, TX
String command = "";
void setup() {
// Motor pins as output
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
// Start hardware Serial for debug output
Serial.begin(9600);
while (!Serial) {
; // Wait for Serial Monitor to open
}
Serial.println("Serial monitor started. Waiting for Bluetooth commands...");
// Start SoftwareSerial for Bluetooth communication
BTSerial.begin(9600);
}
void loop() {
if (BTSerial.available()) {
command = BTSerial.readStringUntil('\n');
command.trim(); // remove whitespace and newline
Serial.print("Command received via Bluetooth: ");
Serial.println(command);
if (command == "forward") {
moveForward();
Serial.println("Moving forward");
} else if (command == "backward") {
moveBackward();
Serial.println("Moving backward");
} else if (command == "left") {
turnLeft();
Serial.println("Turning left");
} else if (command == "right") {
turnRight();
Serial.println("Turning right");
} else if (command == "stop") {
stopMotors();
Serial.println("Stopping motors");
} else {
Serial.println("Unknown command");
}
}
}
void moveForward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
analogWrite(ENA, 200);
analogWrite(ENB, 200);
}
void moveBackward() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENA, 200);
analogWrite(ENB, 200);
}
void turnLeft() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
analogWrite(ENA, 180);
analogWrite(ENB, 180);
}
void turnRight() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
analogWrite(ENA, 180);
analogWrite(ENB, 180);
}
void stopMotors() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
analogWrite(ENA, 0);
analogWrite(ENB, 0);
}
Mobile App (Voice to Bluetooth)
You can use any of these Android apps:
- BT Voice Control for Arduino
- Arduino Bluetooth Control
Tips & Troubleshooting
- Make sure your HC-05 baud rate is 9600.
- Disconnect HC-05 when uploading code to Arduino.
- Use a motor power source (6V–12V battery) capable of supplying enough current.
- Ensure Bluetooth is paired with your phone (default HC-05 password is usually
1234
or0000
).