Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Speech recognition arduino car

Status
Not open for further replies.
Like this?

if(readvoice == "forward")
{
digitalWrite(3, HIGH);
digitalWrite (4, HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
}
 
So BT.begin(9600); is a sort of function statement and works using software serial lines mentioned above in the code

ok I see that now - you are defining your software serial as BT
SoftwareSerial BT(10, 11); //TX, RX respetively

Can you provide a link to the app that you are running on the phone? It appears that maybe that app is doing the speech recognition and then sending a code to the HC-05. That is simple enough, but I suspect that the vocal statements have to be sampled, trained and encoded within the app. It may be that you have only done that for "forward". In other words, it may not be an Arduino code problem but that the app is not recognizing the other voice commands and sending the code.

So, please give us a link for the app that you run on the phone.
 
Maybe it has nothing to do with training - but without the name of the app, it will be difficult to debug.

For example, is it this one?

Once we know that, we can start to divide and concur.

First, I would like to see the format of the string that is being sent to the HC-05 and what your Arduino is seeing.
For example, in the app that I linked to, they tell you the format, e.g.

"if you say Hello the android phone will return a sting *Hello# to your bluetooth module *and # indicate the start and stop bits "

Get where I am going? A short bit of code that will print out the received string is a good starting place - have you done that?
 
I want to move forward for 4 seconds then move right for 2 seconds then wheels should stop

Ok. First, I assume that you do not really want to turn right for 2 seconds as that would be just circling.

Second, I will use your format - but I would restructure the whole thing - never mind that right now.

Third, define a new voice command - "move1"

Fourth, modify your code as follows:

Code:
if (readvoice.length() > 0) {
    Serial.println(readvoice);
    delay(100);

  if(readvoice == "forward")
  {
    digitalWrite(3, HIGH);
    digitalWrite (4, HIGH);
    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    delay(100);
  }

  else if(readvoice == "reverse")
  {
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);
    digitalWrite(6,HIGH);
    delay(100);
  }

  else if (readvoice == "right")
  {
    digitalWrite (3,HIGH);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    delay (100);
 
  }

else if ( readvoice == "left")
{
   digitalWrite (3, LOW);
   digitalWrite (4, HIGH);
   digitalWrite (5, LOW);
   digitalWrite (6, LOW);
   delay (100);
}

else if (readvoice == "stop")
{
   digitalWrite (3, LOW);
   digitalWrite (4, LOW);
   digitalWrite (5, LOW);
   digitalWrite (6, LOW);
   delay (100);
}
else if (readvoice == "move1")
{
// first stop in case you are still moving from another command
   digitalWrite (3, LOW);
   digitalWrite (4, LOW);
   digitalWrite (5, LOW);
   digitalWrite (6, LOW);
   delay (100);
// move forward
    digitalWrite(3, HIGH);
    digitalWrite (4, HIGH);
    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    delay(4000); // for 4 seconds
// stop
   digitalWrite (3, LOW);
   digitalWrite (4, LOW);
   digitalWrite (5, LOW);
   digitalWrite (6, LOW);
   delay (100);
// turn right
    digitalWrite (3,HIGH);
    digitalWrite (4,LOW);
    digitalWrite (5,LOW);
    digitalWrite (6,LOW);
    delay (100);
// move forward
    digitalWrite(3, HIGH);
    digitalWrite (4, HIGH);
    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    delay(2000); // for 2 seconds
// stop
   digitalWrite (3, LOW);
   digitalWrite (4, LOW);
   digitalWrite (5, LOW);
   digitalWrite (6, LOW);
   delay (100);
// done with move1
}
readvoice="";}} //Reset the variable

If you don't know how to add a new voice command, answers the questions I asked about the app and maybe we can help with that.
 

Here is the link for my app that I have developed it accepts all the words and the words are sent from Bluetooth to the car to turn wheels for example if the command is "forward" and also we have programmed our code for forward so the command matches and thus wheels move in forward direction likewise for right case as well as for left and reverse all are trained in the coding and matches so are processed accordingly....
 
Also I want my car move for 2 second in forward direction then turn right and then move in.that direction for 2 seconds then should stop so what I understand from all this logic is like... What you gave for move1 is correct way I think for defining this way using the delay function thankyou so much for your help...
 
I have got idea for how to structure them now I will try it myself .

Once again thanks a lot for your support guys.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top