Voice recognition module v2 code issue

I am working in a voice recognition project and all the comands that I send in Serial depends on the button to execute the sub routines.

This code is all working, but when I press the button (botao), nothing happens.
I am brazilian, so the following code have comments in portuguese. Sorry about my english :confused:
This is part of my code, can you tell me what is wrong?

Here is a bit of my void loop, calling the sub routine "configurarG1" when gets 1 in the serial

void loop() {
  if ( Serial.available() > 0) {
    
    switch (Serial.read())
    {
      case 49: { // numero 1
          Serial.println("Para confirmar a gravacao no grupo 1, pressione o botao");
          if(digitalRead(botao) == LOW){
          configurarG1();
          }
          break;
        }

This is one of the sub routines

void configurarG1()
{
  boolean sinal = 0;


  
    Serial.println("Iniciando gravacao do grupo 1");
    delay(500);

    Serial1.write(0xAA);
    Serial1.write(0x11); //entra no modo de gravacao do grupo 1
    while (sinal == 0) {
      if ( Serial1.available() > 0) //detecta dado na porta serial
      {
        incomingByte = Serial1.read(); //pega dado da serial e parte para o testes
        if (incomingByte == 0xe0) //erro de comando
        {
          Serial.println("Erro de comando");

        }
        else if (incomingByte == 0x40) //fale agora - START
        {
          Serial.println("Fale agora");

        }
        else if (incomingByte == 0x41) //sem voz
        {
          Serial.println("Voz não detectada");

        }
        else if (incomingByte == 0x42) //fale de novo!
        {
          Serial.println("Fale novamente");

        }
        else if (incomingByte == 0x43) //muito alto
        {
          Serial.println("Muito alto");

        }
        else if (incomingByte == 0x44)//diferente
        {
          Serial.println("Comandos diferentes");

        }
        else if (incomingByte == 0x45) //comando gravado
        {
          Serial.println("Comando gravado com sucesso");

        }
      }
      else if (incomingByte == 0x46) //grupo gravado
      {

        Serial.println("Grupo 1 gravado com sucesso");
        sinal = 1;
        Serial.println("Aguardando comando, mestre..");
      }
    }
    Serial1.write(0xAA);
    Serial1.write(0x21);    //incorpora o grupo 1 para utilizar
  sinal = 0;
}

and all the comands that I send in Serial depends on the button to execute the sub routines.

What button? Perhaps you should try a switch, instead.

      case 49: { // numero 1

or

      case '1': { // no silly comment needed
          if(digitalRead(botao) == LOW){
          configurarG1();
          }

Are you holding the switch when the 1 arrives?

You need to separate the reading of the switch from the reading of serial data.

Thank you!! I will see what I can do..

One of my problems was solved with:

estadoBotao = digitalRead(botao);
while ( estadoBotao != LOW ) {
            estadoBotao = digitalRead(botao);
            delay(100);
         }
configurarG1();

Now I am having another issue, when I send 0xAA04 to the module, in datasheet it would return 0xcc or 0xe0, but it is returning the number 65. How can I fix this? 65 is the positive returning or the negative returning?
My code:

 void apagarTudo()
{
  Serial1.write(0xAA);
  Serial1.write(0x04); 
  if (Serial1.available() > 0)
  {    
    incomingByte = Serial1.read();  
  Serial.println(incomingByte);  
    if (incomingByte == 0xcc)
    {
      Serial.println("Grupos apagados com sucesso!");
    }
    else if( incomingByte == 0xe0)
    {
      Serial.println("Erro ao apagar grupos");
    }

  }
}

Thanks in advance

65 is 0x41...

Thanks guys, all problems solved !