Problem in voice control using HC05 module and Android app.

I am using -hc 05 Bluetooth module and AMR android app.

Here is my code:

#include <SoftwareSerial.h>
SoftwareSerial BT(10,11);
String readData;
void setup()
{
 BT.begin(9600);
 Serial.begin(9600);
 pinMode(7,OUTPUT);
}
void loop()
{
 while (BT.available())
 {
  delay(10);
  char c=BT.read();
  readData +=c;
 }
 if(readData.length()>0)
{
Serial.println(readData);
if (readData=="*forward#");
{
  digitalWrite(7,HIGH);
}
if (readData=="*off#"); 
{
  digitalWrite(7,LOW);
}
readData="";
}
}

Problem:

  1. When i say anything(not only forward),led turns on.
  2. When i add second command to code,it didnt work,led only SPARKS...like.
    I know I have written wrongly in code - ';'with if
    [/code]
    if (readData=="*forward#");
    [/code]
    But if I remove it even the above one will not be there,means it not even sparks.(no any effect)
    Reply pls where is the fault and the solution for it.
    Thanks
 while (BT.available())
 {
  delay(10);
  char c=BT.read();
  readData +=c;
 }

While you KNOW that there is data to read, stuff your head in the sand for 99.9% of the time. Why?

That delay() is absolutely the wrong way of ensuring that you get a complete packet.

Apparently all of the packets contain start ('*') and end ('#') markers. Read the data this way, using char arrays, NOT Strings:
Serial input basics - updated

I've never understand why anyone would do anonymous printing. I've never understood why anyone would print a string without some kind of markers before and after the text, so that they could see if there were non-printable characters in the string.

Thanks for you help :slight_smile:
But being new, i didnt understand properly everything.
What exactly i have to do ??pls tell

Tmkocsociety:
What exactly i have to do ??pls tell

One of the things you should do is read through the well thought out tutorial that PaulS linked to for you.
Here is that link again
Serial input basics - updated
Go read through it. It is a fantastic way for someone who is new to learn.

Thanks again :slight_smile:
Is it sure that for both problems, the fault lies only in the code and not in hardware/software parts or connections???
As you have said I read that link ,but can you define me out of that ,exactly which is needed? :slight_smile: :frowning: Thanks.

I will be thankful if anyone gives me the correct code for voice control using bluetooth HC05 module and arduino UNO. :slight_smile:
As I have searched almost every site and video on internet and seen similar to this code only,b ut is not working for me:confused:
How all are able to show correctly that on youtube video ? :o -Pls check any video on youtube for voice control HC05

can you define me out of that ,exactly which is needed?

To do what? Please feel free to explain THAT.