Go Down

Topic: Serial.Write to GEETECH Voice Recognition Module (Read 90 times) previous topic - next topic

Singh_Saab

Hi all.

I ran the code given below on my Arduino Uno and then interfaced it with "GEETECH Voice Recognition Module" (user manual attached below).

The VR module successfully reads my Serial.Write command given in void setup() but not in void loop()!

After the Serial.write(0x21) command in void setup(), VR module successfully imports group 1 of my voice instructions.

But (for example) in Case 0x11 in void loop(), it is supposed to import group 2 of my voice instructions so that I gain access to case 0x21, case 0x22, case 0x23, it is not doing that!


Code: [Select]
void setup()
{
   Serial.begin(9600);

   pinMode(2, OUTPUT);
   pinMode(3, OUTPUT);
   pinMode(4, OUTPUT);
   pinMode(5, OUTPUT);
   pinMode(6, OUTPUT);
   pinMode(7, OUTPUT);
   pinMode(8, OUTPUT);
   pinMode(9, OUTPUT);
   pinMode(10, OUTPUT);  
   pinMode(11, OUTPUT);
   pinMode(12, OUTPUT);
   pinMode(13, OUTPUT);

   delay(2000);

   Serial.write(0xAA);
   Serial.write(0x37);
  
   delay(1000);
  
   Serial.write(0xAA);
   Serial.write(0x21);
}

void loop()
{
   byte k = 0;
   byte led = 0;
   byte com = 0;
  
   while(Serial.available())
   {
      com = Serial.read();
      switch(com)
      {
         case 0x11:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x22);
         digitalWrite(2,HIGH);
         digitalWrite(3, LOW);
         digitalWrite(4, LOW);
         k=1;
         break;

         case 0x12:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x22);
         digitalWrite(2, LOW);
         digitalWrite(3, HIGH);
         digitalWrite(4, LOW);
         k=4;
         break;

         case 0x13:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x22);
         digitalWrite(2, LOW);
         digitalWrite(3, LOW);
         digitalWrite(4, HIGH);
         k=7;
         break;

         case 0x14:
         digitalWrite(2, LOW);
         digitalWrite(3, LOW);
         digitalWrite(4, LOW);
         digitalWrite(5, LOW);
         digitalWrite(6, LOW);
         digitalWrite(7, LOW);
         digitalWrite(8, LOW);
         digitalWrite(9, LOW);
         digitalWrite(10, LOW);
         digitalWrite(11, LOW);
         digitalWrite(12, LOW);
         digitalWrite(13, LOW);
         break;

         case 0x15:
         break;

         case 0x21:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x23);
         led = k+1;
         break;

         case 0x22:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x23);
         led = k+2;
         break;

         case 0x23:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x23);
         led = k+3;
         break;
          
         case 0x24:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x21);
         break;

         case 0x25:
         break;
        
         case 0x31:
         digitalWrite(led, HIGH);
         break;
        
         case 0x32:
         digitalWrite(led, LOW);
         break;
 
         case 0x33:
         delay(1000);
         Serial.write(0xAA);
         Serial.write(0x22);
         break;

         case 0x34:
         break;

         case 0x35:
         break;

         default:
         break;
      }
   }        
}

UKHeliBob

Where does the serial input come from ?  Are you sure that the com variable has the values that you expect ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Singh_Saab

#2
Apr 17, 2016, 09:31 am Last Edit: Apr 17, 2016, 09:40 am by Singh_Saab
I know that the serial.write(0x21) (which is the hex command to import group1) works because case(0x11), case(0x12), case(0x13) are successfully accessed and corresponding LEDs light up. So the com variable has the right values here.


BUT

The serial.write(0x22) (which is the hex command to import group2) in the above mentioned cases under void loop(), does not seem to execute as I don't gain access to case(0x21), case(0x22), case(0x23).

It is stuck in group 1. I know this because only cases corresponding to group 1 are being accessed. Untill and unless serial.write(0x22) or serial.write(0x23) commands is read by my VR module, I cant instruct it any further and I'll stay stuck in group 1.

UKHeliBob

To summarise :

You say that the Arduino is receiving the correct values for the com variable
Therefore the Arduino is sending the correct values

My conclusion would be that there is a problem with the VR unit

What happens if you write a simple program to send commands to the VR unit ?  Does it do what is expected ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Singh_Saab

Thanks for help. I am trying out easier codes first and try to understand what exactly is happening. If I figure it out or need some help, I'll get back to you!

UKHeliBob

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy