Im new to arduino .. pls help ..

I am using an EasyVR module with my arduino board ( indian version ) .. The program below is working .. and when i give a voice command it successfully displays the message in the serial monitor .. i want to make an LED on pin 12 glow instead of displaying the message .. i tried replacing the line
if (c == WORDSET_1_ACTION) { Serial << c << " (WORDSET_1_ACTION)" << endl; }
by
if (c == WORDSET_1_ACTION) { Serial << c << " (WORDSET_1_ACTION)" << endl; digitalWrite(12,HIGH) }
it is not working ... pls help me ....

#include <SoftwareSerial.h>
#include <Streaming.h>
const int rxpin = 2; // pin used to receive from EasyVR
const int txpin = 3; // pin used to send to EasyVR
// argument constants
const byte MINUS_ONE = '@'; // 0x40
const byte ZERO = 'A'; // 0x41
const byte ONE = 'B'; // 0x42
const byte TWO = 'C'; // 0x43
const byte THREE = 'D'; // 0x44
const byte FOUR = 'E'; // 0x45
const byte FIVE = 'F'; // 0x46
const byte SIX = 'G'; // 0x47
const byte SEVEN = 'H'; // 0x48
// command constants
const byte CMD_BREAK = 'b'; // 0x62
const byte CMD_SLEEP = 's'; // 0x73
const byte CMD_KNOB = 'k'; // 0x6B
const byte CMD_LEVEL = 'v'; // 0x76
const byte CMD_LANGUAGE = 'l'; // 0x6C
const byte CMD_TIMEOUT = 'o'; // 0x6F
const byte CMD_RECOG_SI = 'i'; // 0x69
const byte CMD_TRAIN_SD = 't'; // 0x74
const byte CMD_GROUP_SD = 'g'; // 0x67
const byte CMD_UNGROUP_SD = 'u'; // 0x75
const byte CMD_RECOG_SD = 'd'; // 0x64
const byte CMD_ERASE_SD = 'e'; // 0x65
const byte CMD_NAME_SD = 'n'; // 0x6E
const byte CMD_COUNT_SD = 'c'; // 0x63
const byte CMD_DUMP_SD = 'p'; // 0x70
const byte CMD_MASK_SD = 'm'; // 0x6D
const byte CMD_RESETALL = 'r'; // 0x72
const byte CMD_RESETALL_CONFIRM = 'R'; // 0x52
const byte CMD_ID = 'x'; // 0x78
const byte CMD_DELAY = 'y'; // 0x79
const byte CMD_BAUDRATE = 'a'; // 0x61
const byte CMD_QUERY_IO = 'q'; // 0x71
const byte CMD_PLAY_SX = 'w'; // 0x6E
const byte CMD_DUMP_SX = 'h'; // 0x68
// status constants
const byte STS_MASK = 'k'; // 0x6B
const byte STS_COUNT = 'c'; // 0x63
const byte STS_AWAKEN = 'w'; // 0x77
const byte STS_DATA = 'd'; // 0x64
const byte STS_ERROR = 'e'; // 0x65
const byte STS_INVALID = 'v'; // 0x76
const byte STS_TIMEOUT = 't'; // 0x74
const byte STS_INTERR = 'i'; // 0x69
const byte STS_SUCCESS = 'o'; // 0x6F
const byte STS_RESULT = 'r'; // 0x72
const byte STS_SIMILAR = 's'; // 0x73
const byte STS_OUT_OF_MEM = 'm'; // 0x6D
const byte STS_ID = 'x'; // 0x78
const byte STS_PIN = 'p'; // 0x70
const byte STS_TABLE_SX = 'd'; // 0x64
// convenience constants
const byte CMD_ACK = ' '; // 0x20
const byte VRBOT = 'A'; // 0x41
const byte EASYVR = 'B'; // 0x42
// trigger wordset 1 constants
const byte WORDSET_1_ACTION = 'A'; // 0x41
const byte WORDSET_1_MOVE = 'B'; // 0x42
const byte WORDSET_1_TURN = 'C'; // 0x43
const byte WORDSET_1_RUN = 'D'; // 0x44
const byte WORDSET_1_LOOK = 'E'; // 0x45
const byte WORDSET_1_ATTACK = 'F'; // 0x46
const byte WORDSET_1_STOP = 'G'; // 0x47
const byte WORDSET_1_HELLO = 'H'; // 0x48
//
int loop_counter = 0;
SoftwareSerial serial_vr(rxpin, txpin); // new serial port on pins 2 and 3
char c;

void setup()
{
  Serial.begin(9600); // 9600 baud for the built-in serial port
  serial_vr.begin(9600); // initialize the port, EasyVR at power on uses 9600 baud, 8 bit, no parity, 1 stop bit
  Serial.println("setup() complete");
}

void loop()
{
  if (loop_counter == 0)
  {
//    serial_vr.write(0x62); // send 'b' to wake up EasyVR
    serial_vr.write(CMD_BREAK); // send 'b' to wake up EasyVR
    while (Serial.available() == 0) { } // wait for reply
    c = Serial.read(); // read reply byte
    Serial << "awake response: " << c << " ";
    if (c == STS_SUCCESS) { Serial << "(STS_SUCCESS)"; }
    Serial << endl;
    ///
    //serial_vr.print(0x78, BYTE); // send 'x' to request firmware identification
serial_vr.write(CMD_ID);
    while (Serial.available() == 0) { } // wait for reply
    c = Serial.read(); // read reply byte
    Serial << "firmware identification response: " << c << " ";
    if (c == STS_ID) { Serial << "(STS_ID)"; }
    Serial << endl;
    ///
    //serial_vr.print(0x20, BYTE); // send ' ' to acknowledge and read next reply status byte
    serial_vr.write(CMD_ACK); // send ' ' to acknowledge and read next reply status byte
    while (Serial.available() == 0) { } // wait for reply
    c = Serial.read(); // read reply byte
    Serial << "version identifier: " << c << " ";
    if (c == VRBOT) { Serial << "(VRBOT)"; }
    else if (c == EASYVR) { Serial << "(EASYVR)"; }
    Serial << endl;
    ///
    //serial_vr.print(0x6C, BYTE); // send 'l' to set SI language
    //serial_vr.print(0x41, BYTE); // send 'A' (0) for English
    serial_vr.write(CMD_LANGUAGE); // send 'l' to set SI language
    serial_vr.write(ZERO); // send 'A' (0) for English
    while (Serial.available() == 0) { } // wait for reply
    c = Serial.read(); // read reply byte
    Serial << "set SI language: " << c << " ";
    if (c == STS_SUCCESS) { Serial << "(STS_SUCCESS)"; }
    Serial << endl;
    ///
    //serial_vr.print(0x6F, BYTE); // send 'o' to set recognition timeout
    //serial_vr.print(0x46, BYTE); // send 'F' (5) for five seconds
    serial_vr.write(CMD_TIMEOUT); // send 'o' to set recognition timeout
    serial_vr.write(FIVE); // send 'F' (5) for five seconds
    while (Serial.available() == 0) { } // wait for reply
    c = Serial.read(); // read reply byte
    Serial << "set recognition timeout: " << c << " ";
    if (c == STS_SUCCESS) { Serial << "(STS_SUCCESS)"; }
    Serial << endl;
  }
  
  Serial << endl;
  Serial << "speak one of the following words to the EasyVR:" << endl;
  Serial << "action" << endl;
  Serial << "move" << endl;
  Serial << "turn" << endl;
  Serial << "run" << endl;
  Serial << "look" << endl;
  Serial << "attack" << endl;
  Serial << "stop" << endl;
  Serial << "hello" << endl;
  Serial << endl;
  Serial << "loop " << loop_counter++ << ": " << endl;
  ///
  serial_vr.write(CMD_RECOG_SI); // send 'i' to start recognition in wordset 1
  serial_vr.write(ONE); // send 'B' (1) for trigger wordset 1
  while (Serial.available() == 0) { } // wait for reply or exit if wait time greater than recognition timeout
  c = Serial.read(); // read reply byte
  // 'hello' is command index 7 in trigger wordset 1
  if (c == STS_SIMILAR)
  {
    Serial << "successful recognition (STS_SIMILAR)" << endl;
    serial_vr.write(CMD_ACK); // send ' ' to acknowledge and read next reply status byte
    while (Serial.available() == 0) { } // wait for reply
    c = Serial.read(); // read reply byte
    if (c == STS_TIMEOUT) { Serial << "(STS_TIMEOUT)" << endl; }
    else if (c == STS_ERROR)
         {
           Serial << "(STS_ERROR) ";
           serial_vr.write(CMD_ACK); // send ' ' to acknowledge and read next reply status byte
           while (Serial.available() == 0) { } // wait for reply
           c = Serial.read(); // read reply byte
           Serial << c;
           serial_vr.write(CMD_ACK); // send ' ' to acknowledge and read next reply status byte
           while (Serial.available() == 0) { } // wait for reply
           c = Serial.read(); // read reply byte
           Serial << c << endl;
         }
    else
    {
      if (c == WORDSET_1_ACTION) { Serial << c << " (WORDSET_1_ACTION)" << endl; }
      if (c == WORDSET_1_MOVE) { Serial << c << " (WORDSET_1_MOVE)" << endl; }
      if (c == WORDSET_1_TURN) { Serial << c << " (WORDSET_1_TURN)" << endl; }
      if (c == WORDSET_1_RUN) { Serial << c << " (WORDSET_1_RUN)" << endl; }
      if (c == WORDSET_1_LOOK) { Serial << c << " (WORDSET_1_LOOK)" << endl; }
      if (c == WORDSET_1_ATTACK) { Serial << c << " (WORDSET_1_ATTACK)" << endl; }
      if (c == WORDSET_1_STOP) { Serial << c << " (WORDSET_1_STOP)" << endl; }
      if (c == WORDSET_1_HELLO) { Serial << c << " (WORDSET_1_HELLO)" << endl; }
    }
  }
  ///
  delay(1000); // wait one second
  Serial << endl;
}

Don't see a "pinMode (12, OUTPUT);" in there...

Please use code tags when posting code.

Before your program gets much bigger, you may want to investigate the use of PROGMEM for all those strings.

Thanks for the reply .... Gave pinMode(12,OUTPUT) in the setup part ... Still Not working ... :frowning:

So, write a little sketch just to test that the LED connected to pin 12 is actually connected and working.
Something like "blink without delay", but use pin 12, not 13 or whichever pin the example uses.

Please go back to your original post, click on "modify", then highlight the code, then click on the # icon on the toolbar, then click on "save".

I tried this code as you mentioned .. and it works ..

void setup()
{
pinMode(12,OUTPUT);
}
void loop()
{
digitalWrite(12,HIGH);
delay(1000);
digitalWrite(12,LOW);
delay(1000);
}

Good, so wiring isn't your problem.

Hey thanks for your replies ... :slight_smile: i have fixed this problem ..

I need to first setup the VR module by connecting it in the pins 2 and 3 while uploading a new program ...

and then to execute the program i need to connect it on pins 0 and 3 ...

Its working fine Now ... XD :stuck_out_tongue: :slight_smile: