Olá pessol, estou tentando fazer minha EasyVR funcionar com meu Arduino UNO.
Já gravei o BIN no Arduino e baixei a biblioteca da EasyVR na pasta certinha. Mesmo assim deu uma porrada de erros com um projeto simples que fiz. Alguém consegue me dar uma força?
#include "Arduino.h"
#if !defined(SERIAL_PORT_MONITOR)
#error "Arduino version not supported. Please update your IDE to the latest version."
#endif
#if defined(SERIAL_PORT_USBVIRTUAL)
// Shield Jumper on HW (for Leonardo and Due)
#define port SERIAL_PORT_HARDWARE
#define pcSerial SERIAL_PORT_USBVIRTUAL
#else
// Shield Jumper on SW (using pins 12/13 or 8/9 as RX/TX)
#include "SoftwareSerial.h"
SoftwareSerial port(12, 13);
#define pcSerial SERIAL_PORT_MONITOR
#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_ACENDER_LED = 0,
G1_LED_APAGAR = 1,
};
int8_t group, idx;
void setup()
{
pinMode(7, OUTPUT);
// setup PC serial port
pcSerial.begin(9600);
// bridge mode?
int mode = easyvr.bridgeRequested(pcSerial);
switch (mode)
{
case EasyVR::BRIDGE_NONE:
// setup EasyVR serial port
port.begin(9600);
// run normally
pcSerial.println(F("---"));
pcSerial.println(F("Bridge not started!"));
break;
case EasyVR::BRIDGE_NORMAL:
// setup EasyVR serial port (low speed)
port.begin(9600);
// soft-connect the two serial ports (PC and EasyVR)
easyvr.bridgeLoop(pcSerial);
// resume normally if aborted
pcSerial.println(F("---"));
pcSerial.println(F("Bridge connection aborted!"));
break;
case EasyVR::BRIDGE_BOOT:
// setup EasyVR serial port (high speed)
port.begin(115200);
// soft-connect the two serial ports (PC and EasyVR)
easyvr.bridgeLoop(pcSerial);
// resume normally if aborted
pcSerial.println(F("---"));
pcSerial.println(F("Bridge connection aborted!"));
break;
}
while (!easyvr.detect())
{
Serial.println("EasyVR not detected!");
delay(1000);
}
easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println("EasyVR detected!");
easyvr.setTimeout(5);
easyvr.setLanguage(0);
group = EasyVR::TRIGGER; //<-- start group (customize)
}
void action();
void loop()
{
if (easyvr.getID() < EasyVR::EASYVR3)
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());
if (easyvr.getID() < EasyVR::EASYVR3)
easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off
idx = easyvr.getWord();
if (idx >= 0)
{
// built-in trigger (ROBOT)
group = GPOUP_1;
// 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();
// beep
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;
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_ACENDER_LED:
// write your action code here
digitalWrite(7, OUTPUT);
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_LED_APAGAR:
// write your action code here
digitalWrite(7, LOW);
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
}
}
ERROS
Arduino: 1.6.8 (Windows 10), Board: "Arduino/Genuino Uno"
D:\Arduino\Gravações\Gravações.ino: In function 'void setup()':
D:\Arduino\Gravações\Gravações.ino:48:21: error: 'class EasyVR' has no member named 'bridgeRequested'
D:\Arduino\Gravações\Gravações.ino:51:8: error: 'BRIDGE_NONE' is not a member of 'EasyVR'
D:\Arduino\Gravações\Gravações.ino:59:8: error: 'BRIDGE_NORMAL' is not a member of 'EasyVR'
D:\Arduino\Gravações\Gravações.ino:63:12: error: 'class EasyVR' has no member named 'bridgeLoop'
D:\Arduino\Gravações\Gravações.ino:69:8: error: 'BRIDGE_BOOT' is not a member of 'EasyVR'
D:\Arduino\Gravações\Gravações.ino:73:12: error: 'class EasyVR' has no member named 'bridgeLoop'
D:\Arduino\Gravações\Gravações.ino: In function 'void loop()':
D:\Arduino\Gravações\Gravações.ino:98:24: error: 'EASYVR3' is not a member of 'EasyVR'
D:\Arduino\Gravações\Gravações.ino:111:24: error: 'EASYVR3' is not a member of 'EasyVR'
D:\Arduino\Gravações\test.ino: At global scope:
test:13: error: redefinition of 'SoftwareSerial port'
D:\Arduino\Gravações\Gravações.ino:13:18: error: 'SoftwareSerial port' previously declared here
In file included from D:\Arduino\Gravações\test.ino:17:0:
C:\Users\Gui\Documents\Arduino\libraries\EasyVR/EasyVR.h:36:7: error: redefinition of 'class EasyVR'
class EasyVR
^
In file included from D:\Arduino\Gravações\Gravações.ino:17:0:
C:\Users\Gui\Documents\Arduino\libraries\EasyVR/EasyVR.h:36:7: error: previous definition of 'class EasyVR'
class EasyVR
^
In file included from C:\Users\Gui\Documents\Arduino\libraries\EasyVR/EasyVR.h:585:0,
from D:\Arduino\Gravações\test.ino:17:
C:\Users\Gui\Documents\Arduino\libraries\EasyVR/EasyVRBridge.h:17:7: error: redefinition of 'class EasyVRBridge'
class EasyVRBridge
^
In file included from C:\Users\Gui\Documents\Arduino\libraries\EasyVR/EasyVR.h:585:0,
from D:\Arduino\Gravações\Gravações.ino:17:
C:\Users\Gui\Documents\Arduino\libraries\EasyVR/EasyVRBridge.h:17:7: error: previous definition of 'class EasyVRBridge'
class EasyVRBridge
^
test:19: error: redefinition of 'EasyVR easyvr'
D:\Arduino\Gravações\Gravações.ino:19:8: error: 'EasyVR easyvr' previously declared here
test:22: error: multiple definition of 'enum Groups'
D:\Arduino\Gravações\Gravações.ino:22:6: error: previous definition here
test:33: error: multiple definition of 'enum Group1'
D:\Arduino\Gravações\Gravações.ino:28:6: error: previous definition here
test:40: error: redefinition of 'int8_t group'
D:\Arduino\Gravações\Gravações.ino:40:8: error: 'int8_t group' previously declared here
test:40: error: redefinition of 'int8_t idx'
D:\Arduino\Gravações\Gravações.ino:40:15: error: 'int8_t idx' previously declared here
D:\Arduino\Gravações\test.ino: In function 'void setup()':
test:42: error: redefinition of 'void setup()'
D:\Arduino\Gravações\Gravações.ino:42:6: error: 'void setup()' previously defined here
test:50: error: 'class EasyVR' has no member named 'bridgeRequested'
test:53: error: 'BRIDGE_NONE' is not a member of 'EasyVR'
test:61: error: 'BRIDGE_NORMAL' is not a member of 'EasyVR'
test:65: error: 'class EasyVR' has no member named 'bridgeLoop'
test:71: error: 'BRIDGE_BOOT' is not a member of 'EasyVR'
test:75: error: 'class EasyVR' has no member named 'bridgeLoop'
D:\Arduino\Gravações\test.ino: In function 'void loop()':
test:98: error: redefinition of 'void loop()'
D:\Arduino\Gravações\Gravações.ino:96:6: error: 'void loop()' previously defined here
test:100: error: 'EASYVR3' is not a member of 'EasyVR'
test:113: error: 'EASYVR3' is not a member of 'EasyVR'
test:120: error: 'GPOUP_1' was not declared in this scope
D:\Arduino\Gravações\test.ino: In function 'void action()':
test:157: error: redefinition of 'void action()'
D:\Arduino\Gravações\Gravações.ino:154:6: error: 'void action()' previously defined here
test:161: error: 'GROUP_0' was not declared in this scope
exit status 1
redefinition of 'SoftwareSerial port'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.