Hi there.
Currently, I have trouble in using Arduino mega-multi expansion shield for Mega 2560 and easyVR shield.
The expansion shield is called as "Mega-multi Expansion shield" designed by DFROBOT.
This shield can allow Arduino Mega 2560 to use more than 4 other shield.
In order to use easyVR shield with this expansion shield, I am pretty sure about that I need to change code.
But, when I use my changed code, the error sign "easyVR not detected" is kept showing on the serial monitor.
By the way, I have confirmed my easyVR shield is working properly with my Arduino Mega 2560 in direct connection, as described in easyVR manual.
Please, check my changed code and suggest a solution
This code is a simple test code to turn on a LED or Off by voice.
The red color fonts are what I changed for the expansion shield.
/*
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
[color=red] SoftwareSerial port(29,30);[/color]
#else // Arduino 0022 - use modified NewSoftSerial
#include "WProgram.h"
#include "NewSoftSerial.h"
[color=red] NewSoftSerial port(29,30);[/color]
#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_LED_AN = 0,
G1_LED_AUS = 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);
//?L : easyvr.setLanguage(%1!d!);
group = EasyVR::TRIGGER; //<-- start group (customize)
}
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);
}
}
}
void action()
{
switch (group)
{
case GROUP_0:
switch (idx)
{
case G0_ARDUINO:
// write your action code here
group = GROUP_1; //&lt;-- or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_LED_AN:
// write your action code here
group = GROUP_0; //&lt;-- or jump to another group X for composite commands
digitalWrite(13, HIGH); // set the LED on
break;
case G1_LED_AUS:
// write your action code here
group = GROUP_0; //&lt;-- or jump to another group X for composite commands
digitalWrite(13, LOW); // set the LED off
break;
}
break;
}
}
Thank you