Interfacing of EasyVR with Arduino

Hello friends, I hope you all are fine and having fun with your lives. In today's post we are gonna see Interfacing of EasyVR with Arduino UNO. In the previous post, we have seen Getting Started with EasyVR Commander. It was quite simple and if you follow the steps carefully you wont stuck anywhere but still if you into some trouble i am here.

Now this tutorial is quite a quick and important one as it contains the real code using which we will control our robot. After adding the voice commands, now close the EasyVR Commander and open the Arduino Software. Connect the arduino board with computer and double check that your jumper J12 in on position SW. You should also read Training Error: Recognition Failed in EasyVR, if you got such error while working on EasyVR. So, let's get started with Interfacing of EasyVR with Arduino UNO.

Interfacing of EasyVR with Arduino UNO

  • First of all, download the Arduino Libraries for EasyVR Shield, you can easily find them from the official website of EasyVR.
  • Simply connect your Arduino UNO with computer.
  • Open the Arduino Software and copy paste the below code into it.
  • Burn your code in the Arduino Board.
  • Now open your Serial Monitor of ARduino UNO, and you will first see the message saying EasyVR Detected.
  • Now speak any of the command you saved in the board on mic and you will see when the command match the serial terminal will send a specific character.
  • You can change this character if you want to by make a simple change in 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 "EasyVR.h" EasyVR easyvr(port); //Groups and Commands enum Groups { //GROUP_0  = 0, GROUP_1  = 1, }; enum Group0 { G0_ARDUINO = 0, }; enum Group1 { G1_FORWARD = 0, G1_REVERSE = 1, G1_LEFT = 2, G1_RIGHT = 3, G1_STOP = 4, }; 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(EasyVR::ENGLISH); group = EasyVR::TRIGGER; //<-- start group (customize) pinMode(2, OUTPUT); digitalWrite(2, LOW);    // set the LED off pinMode(3, OUTPUT); digitalWrite(3, LOW); pinMode(4, OUTPUT); digitalWrite(4, LOW); pinMode(5, OUTPUT); digitalWrite(5, LOW); pinMode(6, OUTPUT); digitalWrite(6, LOW); } void action(); void loop() { easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening) Serial.print("Say a command in Group"); Serial.println(group); easyvr.recognizeCommand(group); do { // can do some processing while waiting for a spoken command } while (!easyvr.hasFinished()); easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off idx = easyvr.getWord(); if (idx >= 0) { // built-in trigger (ROBOT) // group = GROUP_X; <-- jump to another group X return; } idx = easyvr.getCommand(); if (idx >= 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); } group = GROUP_1; } } 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) { case G1_FORWARD: Serial.print("9"); digitalWrite(2, HIGH); break; case G1_REVERSE: Serial.print("Q"); digitalWrite(3,HIGH); break; case G1_LEFT: Serial.print("X"); digitalWrite(4,HIGH); break; case G1_RIGHT: Serial.print("Y"); digitalWrite(5,HIGH); break; case G1_STOP: Serial.print("Z"); digitalWrite(6,HIGH); break; } break; } }
So, that's all for today. I hope now you can easily Interface EasyVR with Arduino UNO. Have fun and take care !!! :)

Getting Started with EasyVR Commander

In the previous post we have seen the project description of Voice Recognition Project using EasyVR shield. Today we will have a look at Getting started with EasyVR commander. EasyVR shield is a module which is used for voice recognition. First of all, we save our commands in the EasyVR shield and then we use these commands to control anything. In this project, I need to control the robot with voice commands like when someone says FORWARD then the robot start moving in forward direction.

Now first of all what I need to do is to save this FORWARD voice in the shield, which we will see today how to save the command in the shield and after that I will show you the Interfacing of EasyVR shield with Arduino UNO. So that when I say Forward the motor start to move in forward direction, which we will see in the next post. When I was working on EasyVR Shield then I got into a problem which was How to solve Training Error: Recognition Failed in EasyVR and I solved it so you should also have a look at this tutorial if you got such error.

What is EasyVR Commander?

  • EasyVR Commander is a software using which we save the voice commands in the EasyVR Shield. You guys can easily find it using google and its totally free.
  • Download this software and install it.

How to use EasyVR Commander?

  • First of all connect your EasyVR shield with the Arduino UNO Shield as shown in below figure.
 
  • Now be careful in this step as it took the most of my time, on EasyVR shield you will find a jumper J12. Put this jumper on position PC.
Note: When you are adding commands in EasyVR shield using EasyVR Commander, then this jumper J12 must be on position PC and when you are using this shield in the circuit with arduino then this jumper J12 must be on position SW.
  • Connect your Arduino UNO shield with the computer and run the software EasyVR commander. The software will open up as shown in the figure below.
  • Now select the COM Port on which Arduino UNO is attached, which in my case was at COM20.
  • After selecting the COM Port, click the Connect icon as shown in below figure.
  •  When you hit on Connect icon, the software will connect to the COM Port and will open up as shown below:
  •  If you check the left pane, there are many groups and wordset.
  • In wordset, there are pre defined words, which are already saved in the EasyVR shield.
  • The words which I want to save in the shield, will be saved in the Groups.
  • Now to save these words click on any group where you want to save.
  • In the below figure, I have selected Group 2 and then click on the Add Command button (Click # 1) shown in the figure.
  • It will add the command in the group as you can see I have saved the command OK.
  • Now I have saved the command OK but I have to give it some voice to this command.
  • In order to do so, click on the Train Command icon ( Click # 2 ).
  •  Now when you click on the Train Command icon, a message box will pop up as shown in below figure.
  • Click on the button which says Phase 1.
  • Now as you click on this button, a box appears which say "speak now", now its the time to say your command in the mic like I said OK.
  • After listening the command this pop up will again show up and this time the button will be Phase 2.
  • Again click on the button and it will ask for "speak now" and you again speak the same command in the mic.
  • After that the software verifies the two words and if they are same it will confirm the command.
  • You should also have a look at these Arduino Projects for Beginners.
  • In my case, I have saved total 5 commands in my software as shown in the below figure.
  • These were my five commands to control my robot.
  • Now after adding the commands, simply close the software as the voice commands are now saved in the EasyVR shield.
  • Place the jumper J12 back to position SW.
Note:
  • You can also test your added commands,to do so click on Test Command icon on the software and speak up any of the commands from the selected group.
  • If the command matches, then the software will indicate it. Test it and you will see.
In the next post we will check the arduino side of controlling this shield. I will post the code as well so that you can easily test it. If someone's having any problem in using this shield post in comments and I will surely help you out and subscribe us via email to get such exciting tutorials rite in your mailbox. Take care !!!
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir