Importing 2 command groups in GEEETECH voice recognition module

Hello everyone,

I have a project using Geeetech voice recognition module. The project is to switch on/off some electronic devices using voice.

I have 4 devices, So I need 8 commands (4 on / 4 off). So I have to use 2 groups (since Geeetech voice recognition module has 3 groups, each has 5 voice commands - Here is the manuel / Voice_Recognize_manual.pdf )

The problem is that the module can respond to one group at a time only, so I can import one group (I start with group 1 which is the ON commands group), and I can't import the second group at the same time (which is the OFF commands group).

I then got an idea to make the fifth command on group 1 import the group 2 commands, so I can then spell the OFF commands (Also the fifth command of group 2 import the group 1 commands).

The problem now is with the code, I'm not a good programmer so I need your ideas in how to make this work.

Here is the code /

int AC = 9; 
int TV = 10;
int FAN = 11;
int LIGHT = 12;

byte com = 0; //reply from voice recognition
void setup() { 
Serial.begin(9600);
pinMode(AC, OUTPUT);
pinMode(TV, OUTPUT);
pinMode(FAN, OUTPUT);
pinMode(LIGHT, OUTPUT);
Serial.begin(9600);
delay(2000);
Serial.write(0xAA);
Serial.write(0x37);
delay(1000);
Serial.write(0xAA);
Serial.write(0x21); //Importing group 1 commands
}
void loop()
{
  while(Serial.available())
  {
 // Serial.write(0x21);
  com = Serial.read();
  switch(com)
              {
                case 0x11:
                digitalWrite(AC, HIGH);
                break;
                case 0x12:
                digitalWrite(TV, HIGH);
                break;
                case 0x13:
                digitalWrite(FAN, HIGH);
                break;
                case 0x14:
                digitalWrite(LIGHT, HIGH);
                break;
                case 0x15:
                delay(1000);
                Serial.write(0xAA);
                Serial.write(0x22); //Importing group 2 commands
                break;
              
              }
  

  
// Serial.write(0x22);
  com = Serial.read();
  switch(com)
              {
              case 0x11:
                digitalWrite(AC, LOW);
                break;
              case 0x12:
                digitalWrite(TV, LOW);
                break;
                case 0x13:
                digitalWrite(FAN, LOW);
                break;
               case 0x14:
                digitalWrite(LIGHT, LOW);
                break;
                case 0x15:
                delay(1000);
                Serial.write(0xAA);
                Serial.write(0x21);
                break;
              
              }
}
}

I want to transfer from group 1 commands to group 2 commands and break the group 1 loop and stuck in group 2 loop until the command of case 0x15 came and transfer the program to group 1 again. I hope you get the idea.

I’d think that group 1 should have “AC”, “TV”, “FAN”, and “LIGHT”, and that group 2 should have “ON”, “OFF”, and “BACK”.

Then you switch to group 2 when you recognize something in group 1, and switch back to group 1 when you recognize something in group 2.

loop() starts with group 1 active, and a variable that contains the active group. If there is something to read, you know which group contains the command, so you know what to do (save the thing to operate on, if group 1 is active, or change the status of the thing to operate on, unless the command is back, if group 2 is active, change to the other group, and record that the other group is active).

You can also use a simple programming trick. The program first checks if the AC or TV or anything else is on, if it is on it switches it of, else it turns it on. Something like this

case 0x11:

      if(ACState==0){
        digitalWrite(AC,HIGH);
        ACState=1;
      }
      else{
        digitalWrite(AC,LOW);
        ACState=0;
      }

Hello,

I'm here because I'm making something similar with a project of mine, with more than one group and I was wondering if you figured out how to make it work? Would really appreciate it if you can drop a hint or help out :)

Thanks!