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
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;
}