Voice recognition module v3

hi everyone, well i and trying to activate led (which will be replaced by a relay afterwards) using voice recognition module v3 from elechouse. But i am having problems to build a code for it. can anyone help me with the coding please.
i have tried to write a code based on the example given in the library but i could not make it work.

#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
VR myVR(0,1);    // 0:TX 1:RX on v3
uint8_t records[7]; 
uint8_t buf[64];
int led = 8;
#define onRecord    (0)
#define offRecord   (1) 
void setup()
{
  /** initialize */
  myVR.begin(9600);
    Serial.begin(115200);
  Serial.println("Elechouse Voice Recognition V3 Module\r\nControl LED sample");
   pinMode(led, OUTPUT);
}
void loop()
{
  int ret;
  ret = myVR.recognize(buf, 50);
  if(ret>0){
    switch(buf[1]){
      case onRecord:
        /** turn on LED */
        digitalWrite(led, HIGH);
        break;
      case offRecord:
        /** turn off LED*/
        digitalWrite(led, LOW);
        break;
      
    }
   }
}

i am having problems to build a code for it.

Can you please explain what problems you are having ?

This looks wrong

#define onRecord    (0)

When the code is compiled onRecord will be replaced with (0) so
      case onRecord:will become
      case (0):Is that what is intended ?

Have you tried printing buf[1] to see what it contains after the call to yVR.recognize(buf, 50) ?

yes then it become case 0 and case 1 to activate or deactivate the pin

i have just started using the module...im new to it and i have gone through the manual but its really a headache. i have looked at the sample led example and written the code. i am not familiar to some parts of the code. if you can guide me with the code it would be of great help.

Cases are not usually put in round brackets. Was that the way it was done in the example ?
What do you see when you print buf[1] ?

I see you are trying to use the pins 0 & 1 as the pins for the voice recognition module. Also you are attempting to have a serial communication from the Arduino board you are using to your computer. Here you need to mind two things. Firstly when you are using serial communication from an arduino to the computer,the pins 0 and 1 are occupied so any data transferred from pc to Arduino or vice versa will show up on these pins, also no other data can de sent or recieved during the serial link. When you try to use the same 2 pins for the voice recognition module, the board cannot send the two signals from the same pins(just like any other I/O pins) and your data is going nowhere.

So as a solution i would recommend you to use other GPIO pins for the voice recognition module like 2 and 3 (default ) pins and you are goods to go... :slight_smile: :slight_smile: :slight_smile:

Keshav_singh,

better to use the Bluetooth module and an APP for your purpose.
it's much easier. few people struggle and then give up with VR modules.
I had difficulty with EasyVR3, another voice recognition
module, to achieve what I wanted, however I finally managed to get
it going.
.
simply it's not worth the effort. I went through few of these modules
before easyVR3.

MIT APP 2 is an easy tool to develop an APP on android and you can use voice or text.
however, it's your decision that matters. as per dheerajG,
TX and RX pins for receive and transmit data should not be used
for other processing.