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 !!! :)
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 Reply
Reply
Reply
comes trying and he never got it do that Reply