In this blog, I will show you how to build an advanced voice controlled robot with HC-05 bluetooth module and an Arduino microcontroller.
Components required
- Arduino UNO
- HC-05
- Gear Motors
- IC L293D
Arduino UNO
Arduino is an opensource electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor , a finger on a button , or a twitter message - and turn it into an output - activating a motor , turning on a LED , publishing something online. To do so use the Arduino programming language (based on wiring) and the Arduino Software (IDE) based on processing.
HC-05 Bluetooth module
The HC-05 is a popular wireless module that can add two-way (full-duplex) functionality to your projects. You can use this module to communicate between two microcontrollers, such as Arduino, or to communicate with any Bluetooth-enabled device, such as a phone or laptop. Many Android applications are already available, making this process much easier.
Gear Motors
It is a DC motor with a gear box for decreasing the speed and increasing the torque and power . This type of motors is commonly used for robotic applications.
IC L293D
IC L293D is a dual H-bridge motor driver integrated circuit that can drive current of up to 600mA with voltage range of 4.5 to 36 volts.
You can use any bluetooth mobile app available in playstore to connect you mobile to bluetooth module.
Code
#include<SoftwareSerial.h>
int motorPin1 = 3;
int motorPin2 = 4;
int motorPin3 = 5;
int motorPin4 = 6;
SoftwareSerial BT(11, 12);
String readvoice;
void setup() {
BT.begin(9600);
Serial.begin(9600);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
while (BT.available()) {
delay(10);
char c = BT.read();
readvoice += c ;
}
if (readvoice.length() > 0) {
Serial.println(readvoice);
if (readvoice == "forward") {
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, LOW );
delay(100);
}
else if (readvoice == "backward") {
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, HIGH );
delay(100);
}
else if (readvoice == "right") {
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW );
delay(100);
}
else if (readvoice == "left") {
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH );
delay(100);
}
else if (readvoice == "stop") {
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW );
delay(100);
}
readvoice = "";
}
}