Voice recognition and talking problem

hi there

I'm building an arduino robodog using easyVR for the sound recognizition, WTV020SD to make the robot talk, and motor shield to make the robot move.

when I combined the the easyVR and the motor shield everything went fine, however when I added the WTV020SD it stopped working and it won't respond to any of my commands what can I do?

thanks a lot

easyVR
https://www.sparkfun.com/products/12656

motor shield
http://playground.arduino.cc/Main/AdafruitMotorShield

WTV020SD 
http://www.buildcircuit.com/how-to-use-wtv020sd-music-module-with-arduino/

 

the code:

 

#include <SD.h>                      // need to include the SD library
#include <Wtv020sd16p.h> 
int resetPin = 22;  // The pin number of the reset pin.
int clockPin = 23;  // The pin number of the clock pin.
int dataPin = 24;  // The pin number of the data pin.
int busyPin = 25;  // The pin number of the busy pin.
int buttonPushCounter;
Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);

int motion_1 = 122;
#include <AFMotor.h>

uint8_t i;

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int REye = 52; // Analog output pin that the LED is attached to
int LEye = 53; // Analog output pin that the LED is attached to

#if defined(ARDUINO) && ARDUINO >= 100

#include “Arduino.h”

#include “Platform.h”

#include “SoftwareSerial.h”

SoftwareSerial port(12,13);
#endif

#include “EasyVR.h”

EasyVR easyvr(port);

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

enum Group0
{
G0_START = 0,
};

enum Group1
{
G1_RIGHT = 0,
G1_LEFT = 1,
G1_BACK = 2,
G1_GO = 3,
G1_PLAY_DEAD = 4,
};

enum Group2
{
G2_WAKE_UP = 0,
};

EasyVRBridge bridge;

int8_t group, idx;

void setup()
{
wtv020sd16p.reset();
wtv020sd16p.asyncPlayVoice(3);
#ifndef CDC_ENABLED
// bridge mode?
if (bridge.check())
{
cli();
bridge.loop(0, 1, 12, 13);
}
// run normally
Serial.begin(9600);
Serial.println(“Bridge not started!”);
#else
// bridge mode?
if (bridge.check())
{
port.begin(9600);
bridge.loop(port);
}
Serial.println(“Bridge connection aborted!”);
#endif
port.begin(9600);

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);

pinMode(REye, OUTPUT);
pinMode(LEye, OUTPUT);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
group = EasyVR::TRIGGER; //<-- start group (customize)
Serial.println(“Motor test!”);

// turn on motor
motor1.setSpeed(200);
motor2.setSpeed(200);
motor3.setSpeed(200);
motor4.setSpeed(200);

motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
pinMode (motion_1,INPUT);
}

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_START:
/* buttonPushCounter=6;
SelectorPosition();*/
Wake_Up(4,4);
group = GROUP_1;// <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_RIGHT:
buttonPushCounter=2;
SelectorPosition();
stopp();
right(255);
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_LEFT:
buttonPushCounter=3;
SelectorPosition();
stopp();
left(255);
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_BACK:
buttonPushCounter=2;
SelectorPosition();
stopp();
backward(255);
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_GO:
buttonPushCounter=4;
SelectorPosition();
stopp();
forward(255);
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G1_PLAY_DEAD:
buttonPushCounter=5;
SelectorPosition();
stopp();
group = GROUP_2;// <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_2:
switch (idx)
{
case G2_WAKE_UP:
buttonPushCounter=4;
SelectorPosition();
digitalWrite(REye, HIGH); // turn the LED off by making the voltage LOW
digitalWrite(LEye, HIGH); // turn the LED on (HIGH is the voltage level)
group = GROUP_1; //<-- or jump to another group X for composite commands
break;
}
break;
}
}

void SelectorPosition(){
switch (buttonPushCounter) {
case 1:
Serial.println(“song1”);
wtv020sd16p.asyncPlayVoice(0);
wtv020sd16p.stopVoice();

     <span style="color: #008800; font-weight: bold;">break</span>;

case 2:

     Serial.println(<span style="background-color: #fff0f0;">"Song2"</span>);
     wtv020sd16p.asyncPlayVoice(<span style="color: #0000dd; font-weight: bold;">1</span>);
     wtv020sd16p.stopVoice();
     
      <span style="color: #008800; font-weight: bold;">break</span>;

case 3:
Serial.println(“Song3”);
wtv020sd16p.asyncPlayVoice(2);
delay(1000);

     <span style="color: #008800; font-weight: bold;">break</span>;

case 4:
Serial.println(“Song4”);
wtv020sd16p.asyncPlayVoice(3);
delay(1000);

     <span style="color: #008800; font-weight: bold;">break</span>;

case 5:
Serial.println(“Song5”);
wtv020sd16p.asyncPlayVoice(4);
delay(1000);

     <span style="color: #008800; font-weight: bold;">break</span>;

case 6:
Serial.println(“Song6”);
wtv020sd16p.asyncPlayVoice(5);
delay(1000);

     <span style="color: #008800; font-weight: bold;">break</span>;

}
}


thanks for your help :smiley:

May I suggest that you test
May I suggest that you test each item seperately before adding it to the main program.

Yeah, what Arduino board

Yeah, what Arduino board are you using? 

Besides that you need to make sure that you don’t have any conflicts with the pins. Some of them may be used by both shields (sorry I don’t have ti time to check the specs now)

thanks for your answers, I’m

thanks for your answers, I’m using arduino mega, there is no pins conflict I use the empty pins where the shield is not connected and yes I’ve tested each and every part seperately before connecting them, before I added the voice part everything was good

so what can I do ?

 

thanks

First, is there a reason you
First, is there a reason you don’t use capital letters? One of the rules of the forum is to use the best English you can.

Second, does this mean that you had, at one point, everything else disconnected with JUST the voice part connected?

Interrupt conflict
You may have a interrupt conflict. Scan the “library” code you are using to see if two or more modules are trying to connect to the same resource, such as internal timer. As I have not used any of your hardware, this is just a suggestion has to where to start.

the problem solved

sorry for the delay but I’ve been trying all the solution you gave me, and the solution that fixed the error was to remove the sound from the trigger command where the program stopped all the time and it worked fine thanks for all your help.