VOICE CONTROL app with arduino

hi i made an app which has feature to control arduino projects with voice the app is working but the arduino code has some error i dont know wheather the command is received and when the command is received also the arduino is not doing the folllowing task
i have also tested the voice control app available in playstore even tough it is not working pls help me
this school project so pls reply quickly

this is the code:

String voice;
int relay1=A5 ;  
void setup()
{
  Serial.begin(9600);            //Set rate for communicating with phone
  pinMode(relay1, OUTPUT);       //Set relay1 as an output

  digitalWrite(relay1, LOW);
    digitalWrite(relay1, HIGH);
    delay(2000);
  digitalWrite(relay1, LOW); 

}
void loop()
{
  while(Serial.available())    //Check if there are available bytes to read
  {
    delay(10);                 //Delay to make it stable
    char c = Serial.read();    //Conduct a serial read
    if (c == '#'){
      break;                   //Stop the loop once # is detected after a word
    }
    voice += c;                //Means voice = voice + c
  }
    if (voice.length() >0)
    {
      Serial.println(voice);
      if(voice == "*switch on"){
          digitalWrite(relay1, HIGH);
      }              
      else if(voice == "*switch off"){
        digitalWrite(relay1, LOW);
      }               
      voice="";
    }
}

and the app i used for testing is AMR voice from playstore
the code is uploaded but it is not performing any results

connections are
positive of light goes to NO of relay 5v from arduino goes to COM of relay negative of arduino to negative pin of light.bluetooth module's vcc goes to arduino5v and gnd of bt module goes to gnd of arduino and tx of module goes to rx of arduino and rx of module goes to tx of arduino

thank you

Can you also show a screenshot of your blocks? This code looks reasonable at first glance but without seeing how you're interacting with it from the phone there's no way to really understand where the issue lays.

1 Like

if i use my app with another code its working by the way thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.