hello guys
I am using Easyvr with motor driver , when i mounted the motor driver shield over the Easyvr shield , Easyvr stopped listening to commands ,can this problem be solved ???
by the way i am mounting the easyvr shield over arduino uno and the motor driver shield over the the easyvr sheild
thanks in advance for your help
aleem
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
#include <AFMotor.h>
SoftwareSerial port(12,13);
#else // Arduino 0022 - use modified NewSoftSerial
#include "WProgram.h"
#include "NewSoftSerial.h"
#include <AFMotor.h>
NewSoftSerial port(12,13);
#endif
#include "EasyVR.h"
EasyVR easyvr(port);
AF_DCMotor motor(2);
//Groups and Commands
enum Groups
{
GROUP_0 = 0,
GROUP_1 = 1,
GROUP_4 = 4,
GROUP_5 = 5,
};
enum Group0
{
G0_ALEEM = 0,
};
enum Group1
{
G1_GO = 0,
};
enum Group4
{
G4_ONE = 0,
G4_TOW = 1,
G4_THREE = 2,
G4_FOUR = 3,
G4_FIVE = 4,
G4_SIX = 5,
G4_SEVEN = 6,
G4_EIGHT = 7,
};
enum Group5
{
G5_LEFT = 0,
G5_RIGHT = 1,
G5_UP = 2,
G5_DOWN = 3,
G5_FORWARD = 4,
G5_BACKWORD = 5,
};
EasyVRBridge bridge;
int8_t group, idx;
//AF_DCMotor motor(4);
void setup()
{
motor.setSpeed(1000);
// motor1.setSpeed(1000);
// pinMode(5,OUTPUT);
// pinMode(6,OUTPUT);
// 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(0);
group = 5;//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_ALEEM:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_GO:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_4:
switch (idx)
{
case G4_ONE:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G4_TOW:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G4_THREE:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G4_FOUR:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G4_FIVE:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G4_SIX:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G4_SEVEN:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G4_EIGHT:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
case GROUP_5:
switch (idx)
{
case G5_LEFT:
break;
case G5_RIGHT:
break;
case G5_UP:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G5_DOWN:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
case G5_FORWARD:
motor.setSpeed(0);
motor.run(FORWARD);
delay(1000);
break;
case G5_BACKWORD:
motor.setSpeed(1000);
motor.run(BACKWARD);
delay(1000);
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
break;
}
break;
}
}
easyvr_with_motor.txt (5.36 KB)