EasyVR Shield, Arduino Uno interface, software serial connection, voice command control

Interfacing of EasyVR with Arduino

2.5K Views
40
700
60
25
60
PCBWay

Hello friends! We have prepared our spoken commands in EasyVR Commander, and now we will interface the EasyVR Shield with Arduino Uno. In this tutorial, we will read the recognized command, display its result in Serial Monitor, and select an indicator output for FORWARD, REVERSE, LEFT, RIGHT, or STOP.

This is the controller stage of our voice-recognition project. We will preserve the original command order and character codes, while making the program easier to follow and correcting two important problems: listening to the wrong group at startup and leaving previous direction outputs active after a new command.

Begin with LEDs or Serial Monitor. The output pins in this example are indicators, not a complete motor-control circuit. Once you can explain every recognized number and output transition, you can connect the command decisions to a properly designed motor controller.

EasyVR Shield, Arduino Uno interface, software serial connection, voice command control
Figure: The EasyVR Shield and Arduino Uno used for the five-command recognition example.

What We Need Before Uploading the Sketch

Use an Arduino Uno, the original EasyVR Shield, its compatible microphone, and a USB data cable. Install the Arduino IDE and the manufacturer's EasyVR Arduino library. The code below uses its EasyVR.h interface and the Arduino AVR core's SoftwareSerial.h library.

Complete the command training before starting this article. The sketch does not create or train the spoken vocabulary; it expects the five custom commands to exist in the selected group. First establish that Commander recognizes them correctly, then use this program to inspect how Arduino handles their results.

The example targets the Uno and older shield arrangement used in the original project. A Mega, Leonardo, or newer shield can have different serial routing and supported software-serial pins. Check the board documentation before transferring the same pin numbers to another combination.

Set the Shield to Arduino Operation

  1. Disconnect EasyVR Commander so that it releases the serial port.
  2. Remove USB and external power before changing the shield jumper.
  3. Set the original shield's J12 jumper to SW.
  4. Check that the shield headers and microphone connector are secure.
  5. Reconnect USB and select Arduino Uno and its serial port in the IDE.

In this setup, the speech module communicates through software serial on Arduino pins 12 and 13. The hardware serial connection remains available for USB diagnostics. PC mode was useful during direct Commander access, but it is not the operating mode for this standalone sketch. Later hardware should be checked against the manufacturer's shield pin assignments.

Connections and outputs used by the example
Arduino connectionPurposeNote
D12Software-serial receiveReceives data from EasyVR
D13Software-serial transmitSends commands to EasyVR
D2FORWARD indicatorLED with its own series resistor
D3REVERSE indicatorLED with its own series resistor
D4LEFT indicatorLED with its own series resistor
D5RIGHT indicatorLED with its own series resistor
D6STOP indicatorShows the default or cleared state
GNDCommon referenceConnect indicator returns to ground

With each LED connected from an output through a resistor to ground, a HIGH output lights it. Check LED polarity. For an illustrative red LED with a 2 V forward drop and a 5 V output, a 1 kΩ resistor gives approximately (5 − 2) / 1000 = 0.003 A, or 3 mA. Actual LED voltage varies; the calculation explains the resistor's purpose rather than specifying every possible LED.

Match the Trained Group and Command Indexes

Our refreshed series uses Group 1. Its entries must have the following indexes. If your Commander list is different, edit the mapping before testing. Labels are convenient to read, but this sketch selects its action from the returned numeric index.

Command mapping preserved from the original project
IndexCommandOutputCharacter code
0FORWARDD29
1REVERSED3Q
2LEFTD4X
3RIGHTD5Y
4STOPD6Z

The historical Commander screenshots include a Group 2 example. That is not a reason to make the application switch groups after a timeout. Set COMMAND_GROUP to the actual trained group and listen to it from the beginning. This demonstration does not require a separate wake word or trigger group.

Arduino Code for the EasyVR Shield

The example below polls for recognition completion instead of waiting inside an empty loop. It keeps only one indicator active, clears direction indications on an unsuccessful result, and expires a direction indication after two seconds. The indicator timer is a teaching aid; it is not a validated motor-safety mechanism.

#include <Arduino.h>
#include <SoftwareSerial.h>
#include <EasyVR.h>

SoftwareSerial easyvrPort(12, 13); // Arduino RX, TX
EasyVR easyvr(easyvrPort);

const int8_t COMMAND_GROUP = 1;
const uint8_t indicatorPins[] = {2, 3, 4, 5, 6};
const char commandCodes[] = {'9', 'Q', 'X', 'Y', 'Z'};
const unsigned long INDICATION_MS = 2000UL;
const unsigned long RESPONSE_LIMIT_MS = 7000UL;

bool moduleReady = false;
bool listening = false;
bool directionActive = false;
unsigned long directionStarted = 0;
unsigned long listeningStarted = 0;

void selectIndicator(uint8_t index)
{
  for (uint8_t i = 0; i < 5; ++i)
    digitalWrite(indicatorPins[i], LOW);

  digitalWrite(indicatorPins[index], HIGH);
  directionActive = index < 4;
  directionStarted = millis();
}

void setup()
{
  for (uint8_t i = 0; i < 5; ++i) {
    pinMode(indicatorPins[i], OUTPUT);
    digitalWrite(indicatorPins[i], LOW);
  }
  selectIndicator(4);

  Serial.begin(9600);
  easyvrPort.begin(9600);

  if (!easyvr.detect()) {
    Serial.println(F("EasyVR not detected. Check mode and wiring."));
    return;
  }
  if (!easyvr.setTimeout(5)) {
    Serial.println(F("Cannot configure EasyVR. Reset after checking it."));
    return;
  }

  moduleReady = true;
  Serial.println(F("EasyVR detected. Listening to custom Group 1."));
}

void loop()
{
  if (directionActive &&
      millis() - directionStarted >= INDICATION_MS) {
    selectIndicator(4);
    Serial.println(F("Direction indication expired; STOP selected."));
  }

  if (!moduleReady)
    return;

  if (!listening) {
    easyvr.recognizeCommand(COMMAND_GROUP);
    listeningStarted = millis();
    listening = true;
    return;
  }

  if (!easyvr.hasFinished()) {
    if (millis() - listeningStarted >= RESPONSE_LIMIT_MS) {
      selectIndicator(4);
      moduleReady = false;
      listening = false;
      Serial.println(F("No completed response. Check module, then reset."));
    }
    return;
  }

  listening = false;
  const int8_t index = easyvr.getCommand();

  if (index >= 0 && index < 5) {
    selectIndicator(static_cast<uint8_t>(index));
    Serial.print(F("Command index: "));
    Serial.print(index);
    Serial.print(F(" | Code: "));
    Serial.println(commandCodes[index]);
  } else {
    selectIndicator(4);
    if (easyvr.isTimeout()) {
      Serial.println(F("Recognition timed out; no command accepted."));
    } else {
      Serial.print(F("No valid project command. Error: "));
      Serial.println(easyvr.getError());
    }
  }
}

The methods used here are documented in the EasyVR library reference. The code is an updated example for the stated hardware arrangement; compile it with your installed library and test it on indicators before adapting it to another board or application.

Understand the Program Step by Step

Initialize Outputs Before Detecting the Module

The sketch configures D2 through D6 and selects STOP before attempting communication. If module detection fails, the program prints a diagnostic and leaves the direction indicators off. This avoids making successful speech-module initialization a prerequisite for clearing the outputs.

Both serial connections start at 9600 baud in this example. Serial Monitor must use 9600 to display the diagnostic text. That setting is separate from the EasyVR link, even though we use the same numerical rate. If the module has been configured differently, reconcile its configuration with the library setup before expecting detection to succeed.

Start Recognition, Then Poll for Completion

When no recognition request is outstanding, the program starts one for COMMAND_GROUP and records the start time. Subsequent calls to loop() check whether the result is ready. This structure leaves room to service the indicator timer while speech recognition is in progress.

The example requests a five-second recognition timeout. A separate seven-second application deadline detects the absence of a completed response and stops further requests until the board is reset. These are deliberately different checks: the speech module's normal timeout is not the same thing as losing communication with it.

Library calls still take time to communicate, so this is not a hard real-time control loop. Adding a motor, network stack, or long display update requires another timing review. Avoid inserting long delays into the listening loop and assuming that the indication timeout will remain precise.

Validate the Returned Index

The accepted range is zero through four because our table contains five commands. A negative result or an unexpected positive index is rejected before array access. This prevents an unrecognized result from being used as an output-array position.

The selectIndicator() function first clears every indicator and then selects one. FORWARD followed by REVERSE therefore changes the indication instead of accumulating two active directions. STOP selects D6 after clearing D2 through D5. The function is called only with validated indexes or the known STOP index.

Keep the Two Timers Separate

The direction timer uses elapsed time from millis() and returns the indicators to STOP after two seconds. It operates even while another recognition attempt is pending. Subtracting the saved timestamp from the current unsigned timestamp is the usual elapsed-time pattern for intervals of this size.

Changing INDICATION_MS changes only the duration of the visual direction indication. Changing the recognition timeout changes how long EasyVR listens. Neither value describes motor braking time, and neither guarantees that a spoken stop request will be recognized before a moving object reaches an obstacle.

Upload and Run the First Test

  1. Compile the sketch with Arduino Uno selected.
  2. Upload it with the shield in the documented SW arrangement.
  3. Open Serial Monitor at 9600 baud.
  4. Look for the module-detection message.
  5. Say a command that was trained in Group 1.
  6. Compare the reported index and code with the command table.
  7. Observe that the selected direction indication returns to STOP.

For a recognized FORWARD entry at index zero, the diagnostic line should identify index 0 and code 9. A recognized STOP entry should identify index 4 and code Z. These are expected examples of the program's formatting, not a record of a new hardware test performed for this refresh.

Next, say FORWARD and then REVERSE. Check that the old direction indicator turns off. Wait without speaking and observe the timeout behavior. Say an unrelated word and inspect the result. These tests exercise the control decisions that a simple “hello world” recognition demonstration often leaves unexplained.

Run a Repeatable Bench Test

Use the same short sequence whenever you change the program. Start by resetting the Uno and checking that only STOP is selected. Say LEFT, observe D4, and wait for the indication to expire. Say RIGHT next, then STOP before the two-second interval ends. Finally, remain silent through a complete recognition window. Write down any result that differs from the expected state.

This sequence checks startup, a valid direction, automatic clearing, a second direction, an explicit stop, and silence. It is more informative than repeatedly speaking one word. If a result is wrong, inspect the printed index first. A correct index with the wrong LED points toward wiring or output mapping; an incorrect index points toward the trained vocabulary or recognition conditions.

Keep the module powered and its connections undisturbed during normal testing. To inspect startup failure, disconnect power before changing the hardware, then restart with the intended connection absent. The purpose is to observe a controlled fault, not to pull live shield connections and introduce an unrelated electrical problem.

Understand Serial Timing

A conventional asynchronous serial frame with one start bit, eight data bits, and one stop bit uses ten transmitted bits per byte. At 9600 baud, sending a 40-byte diagnostic message therefore occupies approximately 40 × 10 / 9600 = 0.0417 seconds, or 42 milliseconds, on that serial connection.

Buffering affects when the program waits, and this calculation does not describe the EasyVR recognition time. It does show why printing hundreds of characters inside every pass through a fast loop can change application behavior. Print meaningful events, such as a completed recognition or timeout, instead of continuously printing “waiting” while nothing has changed.

Keep a Known Working Configuration

Record the Arduino board package, EasyVR library version, shield revision, trained group, and command table with the sketch. When replacing a library or moving to another board, compile and repeat the indicator test before reconnecting additional hardware. A library update and a wiring change performed together make a new failure harder to explain.

If the compiler reports several errors, begin with the first one. A missing library can produce many later messages that disappear once the include is resolved. If compilation succeeds but detection fails, move to the communication checks; rewriting the command actions will not repair a serial route that never reaches the module.

What the Character Codes Mean

The original project assigned 9, Q, X, Y, and Z to its five actions. We preserve that mapping so existing project notes remain understandable. In this sketch, the character is embedded in a readable diagnostic line alongside its index.

If another controller expects a stream containing only those individual characters, do not connect it to this diagnostic stream unchanged. Messages such as “EasyVR detected” and timeout explanations are not part of that machine protocol. Provide a dedicated output channel or define an explicit framed message format, then keep diagnostic text separate.

A receiving controller should also reject incomplete or unknown messages and have its own timeout. Otherwise a broken connection can leave it acting on an old command indefinitely. Reliable command recognition and reliable command delivery are separate parts of the design.

From Indicators to a Robot

A direction indicator is an abstract request. A motor driver needs specific combinations of direction and enable signals, and different drivers implement stopping differently. For example, disabling a bridge can let a motor coast rather than brake. Read the driver's truth table before deciding what your STOP function should write.

Do not connect a motor to D2, D3, D4, D5, or D6 directly. Choose a power stage that matches the motor's supply voltage and current, provide the required protection and grounding, and keep motor disturbances away from the microphone and logic supply. Test the driver independently before combining it with speech recognition.

For a moving robot, a separate physical stop and a controller-enforced movement limit are necessary design considerations. The first tests should use raised wheels or another restrained setup. Speech recognition can miss a word or identify the wrong one, so it should not be the sole means of preventing unwanted movement.

Troubleshooting the Interface

Diagnosing problems without changing everything at once
SymptomCheckReason
EasyVR.h is missingLibrary installation and include pathThe compiler cannot find the EasyVR interface
Unreadable Serial Monitor outputMonitor baud rateThe USB diagnostic connection uses 9600 baud
Module is not detectedPower, SW mode, serial routing, configured rateSpeech training cannot fix a communication failure
Recognition works only in CommanderSelected custom group and command indexesThe sketch may be listening to a different vocabulary
Wrong indicator lightsIndex table and LED wiringThe recognized number may be mapped incorrectly
Training or recognition fails repeatedlyMicrophone, environment, training consistencyThe input conditions may differ from training

For microphone and training issues, return to Training Error: Recognition Failed in EasyVR. For a compilation problem, note the first compiler error and the installed library version. Changing recognition settings will not resolve a missing header or an unsupported serial-pin assignment.

Project Review

We now have a clear route from a trained command to an Arduino decision. The program listens to the documented group, checks the returned index, clears the previous indication, and reports the selected result. It also separates ordinary recognition timeouts from a missing response and avoids treating an old direction as a permanent instruction.

Keep the next improvement small. You could add an LCD showing the last accepted command or log a sequence of recognition results. Before adding motors or another communications link, document the new pin assignments and timing requirements so that the speech interface remains understandable.

Frequently Asked Questions

Why does the program start with Group 1 instead of a trigger word?

It directly tests the five trained custom commands. A wake-word workflow needs an additional state transition and its own trained or built-in trigger configuration. Add that only after the direct command example works.

Do I need the old NewSoftSerial code branch?

This Uno example uses SoftwareSerial with the Arduino AVR core. The old branch served much older Arduino releases. Use the library and board package appropriate to your installed environment instead of retaining obsolete compatibility code automatically.

Why does a direction indicator turn off without saying STOP?

The example deliberately expires direction indications after two seconds. This makes output lifetime visible during testing. The recognition timeout is separate and does not control that indication period.

Can I use the code without LEDs?

Yes. Serial Monitor still shows accepted indexes and their character codes. The output pins will change as programmed, so keep them disconnected from actuators until you have designed and tested the required interface.

Will the sketch automatically retrain a failed command?

No. Training remains a deliberate Commander operation. The running sketch reports unsuccessful recognition and returns its indicators to STOP. Review and retrain the relevant command separately when necessary.


Comments

41

Join the conversation

2 replies
Reply3

Hello
I am developing a project and need to send data EasyVR for Website, I'm using an Arduino Ethernet shield for that, you have some knowledge on this board? Can you help me?

grateful
Thassilo Jahn

1 reply
Reply4

Hi,
After following your tutorial this is what I get after uploading the sketch ( your sketch..) into the Arduino board.
Upload perfect but serial monitor give: EasyVr not detected.. See the attache file.
The jumper is on SW.
Very very strange.
Firmware is 2.0 and libraries are the most updated..
Best Regards.
Arnaldo

1 reply
Reply4.1
Replying to arnaldo

Your EasyVR shield is not working fine, try it again with EasyVR Commander, if its giving error with EasyVR Commander too then you need to buy a new shield but if its working fine with EasyVR Commander then there's some problem in connection of EasyVR shield with Arduino UNO.

Reply5

Hey,
there are some problem in software program code when i write my code for voice servo control by EasyVr, but i can't detect what is the error, please any suggestion for help me what is the problem, thanks and with all my respect
here is my code:
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
SoftwareSerial port(12,13);
#else // Arduino 0022 - use modified NewSoftSerial
#include "WProgram.h"
#include "NewSoftSerial.h"
NewSoftSerial port(12,13);
#endif
#include
#include "EasyVR.h"
EasyVR easyvr(port);

//Groups and Commands
enum Groups
{
GROUP_0 = 0,
GROUP_1 = 1,
};

enum Group0
{
G0_ARDUINO = 0,
};

enum Group1
{

G1_LEFT = 0,
G1_RIGHT = 1,

};

EasyVRBridge bridge;

int8_t group, idx;

void setup()
{
// bridge mode?
if (bridge.check())
{
cli();
bridge.loop(0, 1, 12, 13);
}
// run normally
Serial.begin(9600);
port.begin(9600);

if (!easyvr.detect())
{
Serial.println("EasyVR not detected!");
for (;;);
}

easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println("EasyVR detected!");
easyvr.setTimeout(5);
easyvr.setLanguage(0);

group = EasyVR::TRIGGER; //= 0)
{
// built-in trigger (ROBOT)
// group = GROUP_X; = 0)
{
// print debug message
uint8_t train = 0;
char name[32];
Serial.print("Command: ");
Serial.print(idx);
if (easyvr.dumpCommand(group, idx, name, train))
{
Serial.print(" = ");
Serial.println(name);
}
else
Serial.println();
easyvr.playSound(0, EasyVR::VOL_FULL);
// perform some action
action();
}
else // errors or timeout
{
if (easyvr.isTimeout())
Serial.println("Timed out, try again...");
int16_t err = easyvr.getError();
if (err >= 0)
{
Serial.print("Error ");
Serial.println(err, HEX);
}
}
}

void action()
{
switch (group)
{
case GROUP_0:
switch (idx)
{
case G0_ARDUINO:
// write your action code here
group = GROUP_1;// <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
// write your action code here
// group = GROUP_X; =1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
} // waits 15ms for the servo to reach the position
}

group = GROUP_0;

// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_RIGHT:
// write your action code here

//forward

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

}

group = GROUP_0;

// group = GROUP_X; <-- or jump to another group X for composite commands
break;

}
break;
}
}

1 reply
Reply5.1
Replying to adiono

Hi,

Whats the problem you are facing in your project ??? Moreover, first of all try simple code of EasyVR given in the Arduino library example to test that EasyVR is working fine, then take it step by step to higher levels. If you need complete assistance on this project then add me on skype and share your project details.

Thanks.

Reply6

i sir…

i’m making project for a college assignment, and my project already done, but my lecturers asked me to make the easyvr just using the arduino uno board as Hardware serial mode.. now i just can make my project use Software serial mode, can u help me. i using arduino uno r3 and the software arduino 1.0.5.-r2, easyvr 1.0, just easyvr without sheild, i also read this:
o HW – Hardware serial mode
Use it for controlling the EasyVR module from your Arduino sketch through the hardware serial port
(using pins 0-1).
o SW – Software serial mode
Use it for controlling the EasyVR module from your Arduino sketch through a software serial port
(using pins 12-13). You can also connect the EasyVR Commander in this mode, provided that the
running sketch implements bridge mode (see libraries).
this is my arduino sketch, and work correctly… thanks

#if defined(ARDUINO) && ARDUINO >= 100
#include “Arduino.h”
#include “SoftwareSerial.h”
SoftwareSerial port(12,13);
#endif

#include “EasyVR.h”
EasyVR easyvr(port);
int a=2;
int b=3;
int c=4;
int d=5;
int aa=6;
int bb=7;
int cc=8;
int dd=9;
int ee=10;
boolean e,f,g,h,pil=false;
//Groups and Commands
enum Groups
{
GROUP_0 = 0,
GROUP_1 = 1,
GROUP_2 = 2,
};

enum Group0
{
G0_AKTIFKAN = 0,
};

enum Group1
{
G1_NYALA = 0,
G1_OFF = 1,
};

enum Group2
{
G2_TV = 0,
G2_LAMPU = 1,
G2_KULKAS = 2,
G2_KIPAS = 3,
G2_SEMUA = 4,
};

EasyVRBridge bridge;

int8_t group, idx;

void setup()
{
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(aa,OUTPUT);
pinMode(bb,OUTPUT);
pinMode(cc,OUTPUT);
pinMode(dd,OUTPUT);
pinMode(ee,OUTPUT);
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(aa,LOW);
digitalWrite(bb,LOW);
digitalWrite(cc,LOW);
digitalWrite(dd,LOW);
digitalWrite(ee,LOW);

// bridge mode?
if (bridge.check())
{
cli();
bridge.loop(0, 1, 12, 13);
}
// run normally
Serial.begin(9600);
port.begin(9600);

if (!easyvr.detect())
{
Serial.println(“EasyVR not detected!”);
for (;;);
}

easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println(“EasyVR detected!”);
easyvr.setTimeout(5);
easyvr.setLanguage(0);

group = EasyVR::TRIGGER; //= 0)
{
// built-in trigger (ROBOT)
// group = GROUP_X; = 0)
{
// print debug message
uint8_t train = 0;
char name[32];
Serial.print(“Command: “);
Serial.print(idx);
if (easyvr.dumpCommand(group, idx, name, train))
{
Serial.print(” = “);
Serial.println(name);
}
else
Serial.println();
easyvr.playSound(0, EasyVR::VOL_FULL);
// perform some action
action();
}
else // errors or timeout
{
if (easyvr.isTimeout())
Serial.println(“Timed out, try again…”);

int16_t err = easyvr.getError();
if (err >= 0)
{
Serial.print(“Error “);
Serial.println(err, HEX);
}
}
}

void action()
{
switch (group)
{
case GROUP_0:

switch (idx)
{
case G0_AKTIFKAN:
// write your action code here
digitalWrite(aa,HIGH);
digitalWrite(bb,LOW);
digitalWrite(cc,LOW);
digitalWrite(dd,LOW);
digitalWrite(ee,LOW);
group = GROUP_2; //<– or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_NYALA:
if(e)
{
digitalWrite(a,HIGH);
e=false;
}
if(f)
{
digitalWrite(b,HIGH);
f=false;
}
if(g)
{
digitalWrite(c,HIGH);

g=false;
}
if(h)
{
digitalWrite(d,HIGH);
h=false;
}
digitalWrite(aa,LOW);
// write your action code here
group = GROUP_0; //<– or jump to another group X for composite commands
break;
case G1_OFF:
if(e)
{
digitalWrite(a,LOW);
e=false;

}
if(f)
{
digitalWrite(b,LOW);
f=false;

}
if(g)
{
digitalWrite(c,LOW);
g=false;

}
if(h)
{
digitalWrite(d,LOW);
h=false;

}
digitalWrite(aa,LOW);
digitalWrite(bb,LOW);
digitalWrite(cc,LOW);
digitalWrite(dd,LOW);
digitalWrite(ee,LOW);

// write your action code here
group = GROUP_0;// <– or jump to another group X for composite commands
break;
}
break;
case GROUP_2:

switch (idx)
{
case G2_TV:
digitalWrite(bb,HIGH);

e=true;
// write your action code here
group = GROUP_1; //<– or jump to another group X for composite commands
break;
case G2_LAMPU:
digitalWrite(cc,HIGH);

f=true;
// write your action code here
group = GROUP_1; //<– or jump to another group X for composite commands
break;
case G2_KULKAS:
digitalWrite(dd,HIGH);

g=true;
// write your action code here
group = GROUP_1; //<– or jump to another group X for composite commands
break;

case G2_KIPAS:
digitalWrite(ee,HIGH);
h=true;
// write your action code here
group = GROUP_1; //<– or jump to another group X for composite commands
break;

case G2_SEMUA:
e=true;
f=true;
g=true;
h=true;
digitalWrite(bb,HIGH);
digitalWrite(cc,HIGH);
digitalWrite(dd,HIGH);
digitalWrite(ee,HIGH);
// write your action code here
group = GROUP_1; //<– or jump to another group X for composite commands
break;
}
break;
}
}

1 reply
Reply6.1
Replying to adiono

Hi,

Yeah its not much difficult to use hardware serial instead of software serial, I haven't used EasyVR with hardware serial before but I dont think its much difficult. Software serial you are using in your code is named as port and you have made a loop between hardware serial and software serial, so what you need to do is to remove the sftware serial library and code and also remove this looping thing and it should work.

If you still get into some trouble then add me on Skype "theenggprojects" and I will resolve it.

Thanks.

Reply7

hi sir

I already editing my arduino sketch, and following your instruction.. but it still using software serial at all, and i dunno whats i have to change in sketch, i already add your skype.. this my new sketch sir

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
SoftwareSerial port(12,13);
#endif

#include "EasyVR.h"
EasyVR easyvr(port);
int a=2;
int b=3;
int c=4;
int d=5;
int aa=6;
int bb=7;
int cc=8;
int dd=9;
int ee=10;
boolean e,f,g,h,pil=false;
//Groups and Commands
enum Groups
{
GROUP_0 = 0,
GROUP_1 = 1,
GROUP_2 = 2,
};

enum Group0
{
G0_AKTIFKAN = 0,
};

enum Group1
{
G1_NYALA = 0,
G1_OFF = 1,
};

enum Group2
{
G2_TV = 0,
G2_LAMPU = 1,
G2_KULKAS = 2,
G2_KIPAS = 3,
G2_SEMUA = 4,
};

EasyVRBridge bridge;

int8_t group, idx;

void setup()
{
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(aa,OUTPUT);
pinMode(bb,OUTPUT);
pinMode(cc,OUTPUT);
pinMode(dd,OUTPUT);
pinMode(ee,OUTPUT);
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(aa,LOW);
digitalWrite(bb,LOW);
digitalWrite(cc,LOW);
digitalWrite(dd,LOW);
digitalWrite(ee,LOW);

// bridge mode?
if (bridge.check())
{
cli();
bridge.loop(0, 1, 12, 13);
}
// run normally

port.begin(9600);

if (!easyvr.detect())
{

for (;;);
}

easyvr.setPinOutput(EasyVR::IO1, LOW);

easyvr.setTimeout(5);
easyvr.setLanguage(0);

group = EasyVR::TRIGGER; //= 0)
{
// built-in trigger (ROBOT)
// group = GROUP_X; = 0)
{
// print debug message
uint8_t train = 0;
char name[32];

if (easyvr.dumpCommand(group, idx, name, train))
{

}
else

easyvr.playSound(0, EasyVR::VOL_FULL);
// perform some action
action();
}
else // errors or timeout
{
if (easyvr.isTimeout())

int16_t err = easyvr.getError();

}
}

void action()
{
switch (group)
{
case GROUP_0:

switch (idx)
{
case G0_AKTIFKAN:
// write your action code here
digitalWrite(aa,HIGH);
digitalWrite(bb,LOW);
digitalWrite(cc,LOW);
digitalWrite(dd,LOW);
digitalWrite(ee,LOW);
group = GROUP_2; //<-- or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_NYALA:
if(e)
{
digitalWrite(a,HIGH);
e=false;
}
if(f)
{
digitalWrite(b,HIGH);
f=false;
}
if(g)
{
digitalWrite(c,HIGH);

g=false;
}
if(h)
{
digitalWrite(d,HIGH);
h=false;
}
digitalWrite(aa,LOW);
// write your action code here
group = GROUP_0; //<-- or jump to another group X for composite commands
break;
case G1_OFF:
if(e)
{
digitalWrite(a,LOW);
e=false;

}
if(f)
{
digitalWrite(b,LOW);
f=false;

}
if(g)
{
digitalWrite(c,LOW);
g=false;

}
if(h)
{
digitalWrite(d,LOW);
h=false;

}
digitalWrite(aa,LOW);
digitalWrite(bb,LOW);
digitalWrite(cc,LOW);
digitalWrite(dd,LOW);
digitalWrite(ee,LOW);

// write your action code here
group = GROUP_0;// <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_2:

switch (idx)
{
case G2_TV:
digitalWrite(bb,HIGH);

e=true;
// write your action code here
group = GROUP_1; //<-- or jump to another group X for composite commands
break;
case G2_LAMPU:
digitalWrite(cc,HIGH);

f=true;
// write your action code here
group = GROUP_1; //<-- or jump to another group X for composite commands
break;
case G2_KULKAS:
digitalWrite(dd,HIGH);

g=true;
// write your action code here
group = GROUP_1; //<-- or jump to another group X for composite commands
break;

case G2_KIPAS:
digitalWrite(ee,HIGH);
h=true;
// write your action code here
group = GROUP_1; //<-- or jump to another group X for composite commands
break;

case G2_SEMUA:
e=true;
f=true;
g=true;
h=true;
digitalWrite(bb,HIGH);
digitalWrite(cc,HIGH);
digitalWrite(dd,HIGH);
digitalWrite(ee,HIGH);
// write your action code here
group = GROUP_1; //<-- or jump to another group X for composite commands
break;
}
break;
}
}

Reply8

HI~ i have tested with the code that i found in the site arduino, but it doesn't work in my board, the part in void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
While compiling, it showed: Servo1_easyvr:209: error: expected `}' at end of input

Could you please help me? THX! here is the code:

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
SoftwareSerial port(12,13);
#else // Arduino 0022 - use modified NewSoftSerial
#include "WProgram.h"
#include "NewSoftSerial.h"
NewSoftSerial port(12,13);
#endif
#include
#include "EasyVR.h"
EasyVR easyvr(port);

//Groups and Commands
enum Groups
{
GROUP_0 = 0,
GROUP_1 = 1,
};

enum Group0
{
G0_ARDUINO = 0,
};

enum Group1
{

G1_LEFT = 0,
G1_RIGHT = 1,

};

EasyVRBridge bridge;

int8_t group, idx;

void setup()
{
// bridge mode?
if (bridge.check())
{
cli();
bridge.loop(0, 1, 12, 13);
}
// run normally
Serial.begin(9600);
port.begin(9600);

if (!easyvr.detect())
{
Serial.println("EasyVR not detected!");
for (;;);
}

easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println("EasyVR detected!");
easyvr.setTimeout(5);
easyvr.setLanguage(0);

group = EasyVR::TRIGGER; //= 0)
{
// built-in trigger (ROBOT)
// group = GROUP_X; = 0)
{
// print debug message
uint8_t train = 0;
char name[32];
Serial.print("Command: ");
Serial.print(idx);
if (easyvr.dumpCommand(group, idx, name, train))
{
Serial.print(" = ");
Serial.println(name);
}
else
Serial.println();
easyvr.playSound(0, EasyVR::VOL_FULL);
// perform some action
action();
}
else // errors or timeout
{
if (easyvr.isTimeout())
Serial.println("Timed out, try again...");
int16_t err = easyvr.getError();
if (err >= 0)
{
Serial.print("Error ");
Serial.println(err, HEX);
}
}
}

void action()
{
switch (group)
{
case GROUP_0:
switch (idx)
{
case G0_ARDUINO:
// write your action code here
group = GROUP_1;// <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
// write your action code here
// group = GROUP_X; =1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
} // waits 15ms for the servo to reach the position
}

group = GROUP_0;

// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_RIGHT:
// write your action code here

//forward

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

}

group = GROUP_0;

// group = GROUP_X; <-- or jump to another group X for composite commands
break;

}
break;
}
}

1 reply
Reply9

Hi, we tried out the same steps for arduino UNO with Easy VR , for voice recognition , but the struggle facing is in the step of
" interfacing EasyVR shield with arduino UNO.... the verification command we received as "Easy VR not detected" after placing the code in the arduino . kindly tell us the steps to follow for this query

1 reply
Reply10

I copied your code and pasted in the IDE 1.0.5 . Now when I verify it , it has got errors. Is there something wrong with the IDE or I am making a mistake. Please reply me I need your help.

1 reply
Reply11

I copied the code and burn it without connecting the easyvr and got the message easyvr not detected and when I connected it I got w and I don't now what is the problem please help me solve it

1 reply
Reply11.1
Replying to adiono

Hi,

It means that your code is working fine, Its just you are not getting what you are trying to do, first understand the code what it is doing then do it. Check from where this w is coming. If the problem still remains then let me know and we will sort it out.

Thanks.

Reply12

yes the code is fine .. I tried the example and I also get the w in serial monitor when I connect the easy vr . the problem is where is this w comes from ??
thank you ..

1 reply
1 reply
1 reply
Reply13

Can this project be performed using a PIC board ? what library would i have to use bcz there is only an arduino library
Any assistance ?

1 reply
Reply14

Hello
I'm facing the same problem as the guy above, it keeps saying bridge not started and easyvr not detected when the shiled is not connected to the arduino, as soon as I connect them, the serial monitor stops and nothing appears on it. what is the correct way to run the codes?, to burn it onto the arduino, I disconnect the shield coz if I didn't it will say the port is used. then once its done, I open the serial monitor (and restart the arduino), it shows me that the bridge is not started and the easyvr is not detected. as soon as I connect it it shows nothing!. regarding the simpler examples to check if its working, which ones should I try and what output should I expect?(I also need to know the correct steps to run it first).
thank you very much I your post is VERY helpful!!

Isra

1 reply
Reply14.1
Replying to adiono

Oh its fine I got it fixed, it seems that the shield was not placed properly over the board (i had to push it deeper, but not too much). The new problem is that it keeps telling me timeout, try again even if I said a command. what to do now?

Reply15

Hey there. Your tutorial was great. But I need some help here.
I'm trying to connect "Stand alone EasyVR" to Beaglebone black through RX and TX lines.
Also, I have a script which reads data from the RX and TX lines and displays it on the console
So, what would be the output if I do that.
Will it be the keywords printing on the console or some characters and numbers???
Thank you in advance.

Sincerely,
Suraj

1 reply
Reply15.1
Replying to adiono

Hi,

It depends on the programming you are writing. First of all, you upload voices in the EasyVR shield and after that you put some checks in the beaglebone to detect whether your voices are getting detected or not. You have to do testing and its better if you try to find some EasyVR library for BeagleBone. If you still getting problem then add me on Skype and I will check it out.

Thanks.

1 reply
Reply17

Hi,

I am having some trouble uploading the code onto the EasyVR shield 2.0. Can you help? The errors can be seen below. This is after I tried uploading the code that you provided on to the shield.

Arduino: 1.6.1 (Windows 7), Board: "Arduino Uno"

Build options changed, rebuilding all

EasyVRTest.ino:56:1: error: stray '\' in program

EasyVRTest.ino:56:1: error: stray '\' in program

EasyVRTest.ino:61:1: error: stray '\' in program

EasyVRTest.ino:61:1: error: stray '\' in program

EasyVRTest.ino:86:1: error: stray '\' in program

EasyVRTest.ino:86:1: error: stray '\' in program

EasyVRTest.ino:111:1: error: stray '\' in program

EasyVRTest.ino:111:1: error: stray '\' in program

EasyVRTest.ino:115:1: error: stray '\' in program

EasyVRTest.ino:115:1: error: stray '\' in program

EasyVRTest.ino:127:1: error: stray '\' in program

EasyVRTest.ino:127:1: error: stray '\' in program

EasyVRTest.ino:127:1: error: stray '\' in program

EasyVRTest.ino:131:1: error: stray '\' in program

EasyVRTest.ino:131:1: error: stray '\' in program

EasyVRTest.ino:156:1: error: stray '\' in program

EasyVRTest.ino:156:1: error: stray '\' in program

EasyVRTest.ino:160:1: error: stray '\' in program

EasyVRTest.ino:160:1: error: stray '\' in program

EasyVRTest.ino:164:1: error: stray '\' in program

EasyVRTest.ino:164:1: error: stray '\' in program

EasyVRTest.ino:168:1: error: stray '\' in program

EasyVRTest.ino:168:1: error: stray '\' in program

EasyVRTest.ino:172:1: error: stray '\' in program

EasyVRTest.ino:172:1: error: stray '\' in program

EasyVRTest.ino: In function 'void setup()':

EasyVRTest.ino:56:17: error: 'u201cEasyVR' was not declared in this scope

EasyVRTest.ino:61:17: error: 'u201cEasyVR' was not declared in this scope

EasyVRTest.ino: In function 'void loop()':

EasyVRTest.ino:86:15: error: 'u201cSay' was not declared in this scope

EasyVRTest.ino:111:27: error: found ':' in nested-name-specifier, expected '::'

EasyVRTest.ino:111:15: error: 'u201cCommand' has not been declared

EasyVRTest.ino:115:15: error: 'u201d' was not declared in this scope

EasyVRTest.ino:115:24: error: 'u201c' was not declared in this scope

EasyVRTest.ino:127:17: error: 'u201cTimed' was not declared in this scope

EasyVRTest.ino:127:33: error: expected primary-expression before 'try'

EasyVRTest.ino:131:15: error: 'u201cError' was not declared in this scope

EasyVRTest.ino: In function 'void action()':

EasyVRTest.ino:156:15: error: 'u201c9' was not declared in this scope

EasyVRTest.ino:160:15: error: 'u201cQ' was not declared in this scope

EasyVRTest.ino:164:15: error: 'u201cX' was not declared in this scope

EasyVRTest.ino:168:15: error: 'u201cY' was not declared in this scope

EasyVRTest.ino:172:15: error: 'u201cZ' was not declared in this scope

Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

1 reply
Reply18

i've bought arduino mega2560 and i connect it with easyVr and i program my own code and it runs and i control leds , but now i can only upload any code in my arduino but when i connect it with easyVr shiled and try to upload the code this is the main error that I get ,The full list of errors is as follows:
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
can you help me please

Reply19

Hello,

I am pretty new to programming but, I do not see that your code factors in a motor driver anyware. Is this difficult to do? Could you show me how to modify the code to accomplish this?

Thanks

1 reply
Reply20

good morning mr Syed Zain Nasir, I am currently working on almost the same exact project you're doing involving using the Easy VR shield with arduino. Im also making my robot move forward, reverse, left, right and stop. I did everything you mentioned in the post on the engineeringprojects website. Except when I copy and pasted the code there was an error saying this and im not sure why is this an error. Everything else is good.

This is It "exit status 1 - EasyVrBridge does not name a type"

I need your help because I am trying to finish up this project for my engineering course

1 reply
Reply21

Hello, I have a problem. I tested my robot with the code, it works without any problem...But if I disconect the USB, it doesn't recognise the comands anymore...it works only while the usb is connected... why? Can you tell me please? I really can't find a solution...