Voice Recognition Module

Hi everyone. First of all, i'm really new on Arduino and at Programing, all i've learned was on internet, so it's not even 50% good. I bought an Voice Recognition Module on Aliexpress.com from geeetch. My dificult is programing to use the answer that module gives to my Arduino UNO.

Exemple, most of modules would return Arduino something like "Result:11" but for me to do this its necessary to creat a String (String voice = (Serial.readString()). Creating a String i can't use "switch()...case", its needed to use "If()...else". And using "if" the code works, but not as i want, and when i say to execute the last comand, it executes 1, 2, 3, 4 and then, 5

What should i do?

const int AZUL = A4; //LEDs Azul
const int VERMELHO = A2; //LEDs Vermelhos                                                      
const int VERDE = A5; //LEDs Verdes
const int ReleLuz = 4; //Rele da Luz
const int Lasers = 6; //Lasers
  
  
void setup() {
  Serial.begin(9600); 
  delay(1000);
  Serial.write(0xAA);
  Serial.write(0x36);
  delay(1000);
  Serial.write(0xAA);
  Serial.write(0x21); 
  pinMode (ReleLuz, OUTPUT);
  pinMode (Lasers, OUTPUT);
  pinMode (VERMELHO, OUTPUT);
  pinMode (VERDE, OUTPUT);
  pinMode (AZUL, OUTPUT);
}







  
void loop()
{
  
 Inicio: delay(1000);

 while(Serial.available())
   { 
     String com = String(Serial.read(), HEX);
      String Arduino, ON, Vermelho = "526573756c743a3131da";
      String Luzes, OFF, Verde = "526573756c743a3132da";
      String Vento, LED, Azul = "526573756c743a3133da";
      String Laser, Mais, Pulsar= "526573756c743a3134da";
      String Desligar, Menos, Branco= "526573756c743a3135da";
      Serial.print (com);
      
     
    if (com.startsWith(Arduino))
     { 
       digitalWrite (VERMELHO,1); 
       digitalWrite (VERDE,0);
       digitalWrite (AZUL ,0);
       goto Inicio;
     }
    else {goto Inicio;};
    break;
   }

  
       
       
       
       
 while(Serial.available())
   { 
     String com = String(Serial.read(), HEX);
      String Arduino, ON, Vermelho = "526573756c743a3131da";
      String Luzes, OFF, Verde = "526573756c743a3132da";
      String Vento, LED, Azul = "526573756c743a3133da";
      String Laser, Mais, Pulsar= "526573756c743a3134da";
      String Desligar, Menos, Branco= "526573756c743a3135da";
      Serial.print (com);
      
       
       
     
            if (com.startsWith(Luzes))
              { 
               digitalWrite (VERMELHO, 0);
               digitalWrite (VERDE, 1);
               //digitalWrite (AZUL , HIGH);               
               analogWrite ( AZUL, 0); 
               digitalWrite (Lasers, LOW);
        goto Inicio;
     }
    //else {goto Inicio;};
    break;
   }

           
                 
                 
                 
                 
                 



 while(Serial.available())
   { 
     String com = String(Serial.read(), HEX);
      String Arduino, ON, Vermelho = "526573756c743a3131da";
      String Luzes, OFF, Verde = "526573756c743a3132da";
      String Vento, LED, Azul = "526573756c743a3133da";
      String Laser, Mais, Pulsar= "526573756c743a3134da";
      String Desligar, Menos, Branco= "526573756c743a3135da";
      Serial.print (com);
                 
                 
         if (com.startsWith(Laser))
          {
            digitalWrite (VERMELHO, 0);
            digitalWrite (VERDE, 0);
            digitalWrite (AZUL , 1);
            digitalWrite (Lasers, HIGH);
            digitalWrite (ReleLuz, LOW);
       goto Inicio;
     }
    //else {goto Inicio;};
    break;
   }


   
   
   
   




 while(Serial.available())
   { 
     String com = String(Serial.read(), HEX);
      String Arduino, ON, Vermelho = "526573756c743a3131da";
      String Luzes, OFF, Verde = "526573756c743a3132da";
      String Vento, LED, Azul = "526573756c743a3133da";
      String Laser, Mais, Pulsar= "526573756c743a3134da";
      String Desligar, Menos, Branco= "526573756c743a3135da";
      Serial.print (com);
   
   
   
          if (com.startsWith(Vento))
          {
                        digitalWrite (VERMELHO, 1);
            digitalWrite (VERDE, 0);
            digitalWrite (AZUL , 1);
       goto Inicio;
     }
    //else {goto Inicio;};
    break;
   }



  
  
  
  
  


 while(Serial.available())
   { 
     String com = String(Serial.read(), HEX);
      String Arduino, ON, Vermelho = "526573756c743a3131da";
      String Luzes, OFF, Verde = "526573756c743a3132da";
      String Vento, LED, Azul = "526573756c743a3133da";
      String Laser, Mais, Pulsar= "526573756c743a3134da";
      String Desligar, Menos, Branco= "526573756c743a3135da";
      Serial.print (com);
  
  
  
   
      
          if (com.startsWith(Desligar))
          {
            digitalWrite (Lasers, LOW);
            digitalWrite (ReleLuz, 0);
            digitalWrite (VERMELHO, LOW);
            digitalWrite (VERDE, LOW);
            digitalWrite (AZUL , LOW);
       goto Inicio;
     }
    else {  };


       break;
           }

   }

but for me to do this its necessary to creat a String

It most certainly is not.

      String Luzes, OFF, Verde = "526573756c743a3132da";

            if (com.startsWith(Luzes))

What value do you think is in Luzes at that point? Any answer other than nothing is wrong.

You should have ONE block of code to read from the serial port. ONE!

Get rid of the stupid goto statement. loop() is called that for a reason!

Please read the posts by Nick Gammon at the top of this Forum for guidelines on posting here. For posting source code, use the code tags ("</>") not the quotation icon. This will make it easier for us to help you.

You might also spend some time with Robin’s post at the top of the Forum and then experiment with the Communications examples that are distributed with the IDE (e.g., File → Examples → Communications).

Sorry for that, i´m really new on this. So... I've done the changes and still doesn't work, what can be?

const int AZUL = A4; //LEDs Azul
const int VERMELHO = A2; //LEDs Vermelhos                                                      
const int VERDE = A5; //LEDs Verdes
const int ReleLuz = 4; //Rele da Luz
const int Lasers = 6; //Lasers
  
  
void setup() {
  Serial.begin(9600); 
  delay(1000);
  Serial.write(0xAA);
  Serial.write(0x36);
  delay(1000);
  Serial.write(0xAA);
  Serial.write(0x21); 
  pinMode (ReleLuz, OUTPUT);
  pinMode (Lasers, OUTPUT);
  pinMode (VERMELHO, OUTPUT);
  pinMode (VERDE, OUTPUT);
  pinMode (AZUL, OUTPUT);
}







  
void loop()
{
  


 while(Serial.available())
   { 
     String com = String(Serial.read(), HEX);
      String Arduino = ("526573756c743a3131da");
      String Luzes  = ("526573756c743a3132da");
      String Vento  = ("526573756c743a3133da");
      String Laser = ("526573756c743a3134da");
      String Desligar = ("0x526573756c743a3135da");
      Serial.print (com);
      
     
    if (com.endsWith(Arduino))
     { 
       digitalWrite (VERMELHO,1); 
       digitalWrite (VERDE,0);
       digitalWrite (AZUL ,0);
       delay(50);
       //break;
       
       
     }
    else { };
    break;
   


     
            if (com.startsWith(Luzes))
              { 
               digitalWrite (VERMELHO, 0);
               digitalWrite (VERDE, 1);
               analogWrite ( AZUL, 0); 
               digitalWrite (Lasers, LOW);
               delay(50);
             //  break;
        
     }
    else {};
    break;
   

           
                 
                 
                 
                 
                 

    if (com.startsWith(Laser))
          {
            digitalWrite (VERMELHO, 0);
            digitalWrite (VERDE, 0);
            digitalWrite (AZUL , 1);
            digitalWrite (Lasers, HIGH);
            digitalWrite (ReleLuz, LOW);
            delay(50);
        //    break;
      
     }
    else {};
    break;
   


   
          if (com.startsWith(Vento))
          {
            digitalWrite (VERMELHO, 1);
            digitalWrite (VERDE, 0);
            digitalWrite (AZUL , 1);
            delay(50);
        //    break;
       
     }
    else {};
    break;
   

   
      
          if (com.startsWith(Desligar))
          {
            digitalWrite (Lasers, LOW);
            digitalWrite (ReleLuz, 0);
            digitalWrite (VERMELHO, LOW);
            digitalWrite (VERDE, LOW);
            digitalWrite (AZUL , LOW);
            delay(50);
        //    break;
       
     }
    else {};
break;
   }
       
           }
     String com = String(Serial.read(), HEX);

Serial.read() reads ONE byte from the incoming serial buffer. Converting that to a String just pisses away resources needlessly.

That one character String is NEVER going to end with "526573756c743a3131da".

Forget trying to USE the data. Work on how to READ the data.

PaulS:     String com = String(Serial.read(), HEX);

Serial.read() reads ONE byte from the incoming serial buffer. Converting that to a String just pisses away resources needlessly.

That one character String is NEVER going to end with "526573756c743a3131da".

Forget trying to USE the data. Work on how to READ the data.

PaulS, What you sugest me to do?

PaulS, What you sugest me to do?

Find Robin2's post on how to read serial data. Pay attention.