Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
kridtapas
Published © MIT

Control Car by Voice via Bluetooth

Control the motion of a car with speech commands using voice control and Bluetooth modules.

IntermediateFull instructions provided3 hours1,399
Control Car by Voice via Bluetooth

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×2
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Geeetech Voice Recognition Module & microphone USB to RS232 TTL Converter Dupont
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×2
9V battery (generic)
9V battery (generic)
×3

Software apps and online services

Arduino IDE
Arduino IDE
Access port

Story

Read more

Custom parts and enclosures

Instruction voice recognition.

Schematics

Block diagram master.

Block diagram slave.

Code

Voice Controll The Car via Bluetooth.(MASTER).

Arduino
Everyone can edit for apply your project.
//Voice Controll The Car via Bluetooth.(MASTER).
//Author::Kridtapas Rordtook.
//Start::6-9-2561.
//Version1.

//Include Library for communicate between module voice.
#include <SoftwareSerial.h>//////////

SoftwareSerial mySerial(10, 11); //RX, TX.

//Set Global Variable.
byte com = 0;
byte M, L, R, S, B = 0;

void setup() {
  //MASTER-SLAVE.
  Serial.begin(38400); // Default communication rate of the Bluetooth module
  //Communicate Module Voice.
  mySerial.begin(9600);
  delay(2000);
  mySerial.write(0xAA);
  mySerial.write(0x37);
  delay(1000);
  mySerial.write(0xAA);
  mySerial.write(0x22);
}

void loop() {
  while(mySerial.available()) {
  com = mySerial.read();
    switch(com) {
        case 0x11:   //0x11 is command 1 is for M --> Forward.()
          Serial.print('1');
          delay(500);
        break;
        case 0x12:  //0x12 is command 2 is for L --> Turn-Left and Forward.()
          Serial.print('2');
          delay(500);
        break;
        case 0x13:  //0x13 is command 3 is for R --> Turn-Right and Forward.()
          Serial.print('3');
          delay(500);
        break;
        case 0x14:  //0x14 is command 4 is for S --> Stop and not Move.()
          Serial.print('4');
          delay(500);
        break;
        case 0x15:  //0x15 is command 5 is for B --> Backward.()
          Serial.print('5');
          delay(500);
        break;
    }
  }
}

//Voice Controll The Car via Bluetooth.(SLAVE).

Arduino
Everyone can edit for apply your project.
//Voice Controll The Car via Bluetooth.(SLAVE).
//Author::Kridtapas Rordtook.
//Start::6-9-2561.
//Version1.

//Define pin of board drive motor.
#define motor1a 2
#define ena 3
#define motor2a 4
#define enb 11
#define motor1b 7
#define motor2b 12

//Collect state of slave.
int state = 0;

void setup() {
  // put your setup code here, to run once:
  //Set Serial between MASTER and SLAVE.
  Serial.begin(38400); // Default communication rate of the Bluetooth module
  //Set IO_Pin.
  pinMode(motor1a, OUTPUT);
  pinMode(motor2a, OUTPUT);
  pinMode(motor1b, OUTPUT);
  pinMode(motor2b, OUTPUT);
  pinMode(ena, OUTPUT);
  pinMode(enb, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 if(Serial.available() > 0){ // Checks whether data is comming from the serial port
    state = Serial.read(); // Reads the data from the serial port
 }
 //Part Controll.
 if (state == '1') {//Forward.
  //Forward-Forward.
  analogWrite(ena, 127);// numeral is speed come from PWM.
  analogWrite(enb, 127);
  digitalWrite(motor1a, HIGH);digitalWrite(motor2a, LOW); 
  digitalWrite(motor1b, HIGH);digitalWrite(motor2b, LOW);
 }
 else if (state == '2') {//Turn-Left and Forward.
  //Turn-Left.
  analogWrite(ena, 85);
  analogWrite(enb, 0);
  digitalWrite(motor1a, HIGH);digitalWrite(motor2a, LOW); 
  digitalWrite(motor1b, LOW);digitalWrite(motor2b, LOW);
 }
 else if (state == '3'){//Turn-Right and Forward.
  //Turn-Right.
  analogWrite(ena, 0);
  analogWrite(enb, 60);
  digitalWrite(motor1a, LOW);digitalWrite(motor2a, LOW); 
  digitalWrite(motor1b, HIGH);digitalWrite(motor2b, LOW);
 }
 else if (state == '4'){//Stop.
  //Slow Stop-Stop.
  analogWrite(ena, 0);
  analogWrite(enb, 0);
  digitalWrite(motor1a, LOW);digitalWrite(motor2a, LOW); 
  digitalWrite(motor1b, LOW);digitalWrite(motor2b, LOW);
 }
 else if (state == '5'){//Backward.
  //Backward-Backward.
  analogWrite(ena, 127);
  analogWrite(enb, 127);
  digitalWrite(motor1a, LOW);digitalWrite(motor2a, HIGH); 
  digitalWrite(motor1b, LOW);digitalWrite(motor2b, HIGH);
 }
}

Credits

kridtapas
1 project • 1 follower
contact me kridtapaspeem@gmail.com
Contact

Comments

Please log in or sign up to comment.