Go Down

Topic: I need help with this code... (Read 157 times) previous topic - next topic

AvramIonut

Jun 27, 2015, 02:18 pm Last Edit: Jun 28, 2015, 10:50 am by AvramIonut
Hi everyone,

I've just started to work on a project using EasyVR Shield for Arduino uno Rev3 but i encountered an unexpected error in my code.

I've uploaded a code which is supposed to print in the serial monitor some strings according to my vocal commands.

Can you give me a help and explain me what does thie error means?

Quote
Quote
In file included from C:\Users\Ionut\Documents\Arduino\libraries\NewSoftSerial\NewSoftSerial.cpp:39:0:
C:\Users\Ionut\Documents\Arduino\libraries\NewSoftSerial\NewSoftSerial.h:70:16: error: conflicting return type specified for 'virtual void NewSoftSerial::write(uint8_t)'
   virtual void write(uint8_t byte);
In file included from C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/Stream.h:26:0
                from C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/HardwareSerial.h:29,
               from C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/Arduino.h:223,
               from C:\Users\Ionut\Documents\Arduino\libraries\NewSoftSerial\NewSoftSerial.cpp:37:
Quote
C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/Print.h:48:20: error:   overriding 'virtual size_t Print::write(uint8_t)'
   virtual size_t write(uint8_t) = 0;

AvramIonut

Hey guys,

I've started to work on a project using EasyVR and Arduino.

I've uploaded this code...
Quote
#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_PLAY = 0,
G1_PAUSE = 1,
G1_PREVIOUS = 2,
G1_NEXT = 3,
G1_STOP = 4,
G1_VOLUME_UP = 5,
G1_VOLUME_DOWN = 6,
G1_MINIMIZE = 7,
G1_MUTE = 8,
G1_FULLSCREEN = 9,
G1_FOCUS_VIDEO = 10,
G1_FOCUS_PHOTO = 11,
G1_CLOSE = 12,
};

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_PLAY:
Serial.print("PLAY");
digitalWrite(2, HIGH);
break;
case G1_PAUSE:
Serial.print("PAUSE");
digitalWrite(3,HIGH);
break;
case G1_PREVIOUS:
Serial.print("PREVIOUS");
digitalWrite(4,HIGH);
break;
case G1_NEXT:
Serial.print("NEXT");
digitalWrite(5,HIGH);
break;
case G1_STOP:
Serial.print("STOP");
digitalWrite(6,HIGH);
break;
/*case G1_VOLUME_UP:
Serial.print("INCRESING VOLUME...");
digitalWrite(7,HIGH);
break;
case G1_VOLUME_DOWN:
Serial.print("DECREASING VOLUME...");
digitalWrite(8,HIGH);
break;
case G1_MINIMIZE:
Serial.print("MINIMIZE");
digitalWrite(9,HIGH);
break;
case G1_MUTE:
Serial.print("MUTE");
digitalWrite(10,HIGH);
break;
case G1_FULLSCREEN:
Serial.print("X");
digitalWrite(11,HIGH);
break;*/
/*case G1_FOCUS_VIDEO:
Serial.print("Y");
digitalWrite(12,HIGH);
break;
case G1_FOCUS_PHOTO:
Serial.print("Z");
digitalWrite(13,HIGH);
break;
case G1_CLOSE:
Serial.print("CLOSE");*/
//digitalWrite(13,HIGH);

}
break;
}
}
BUT i have this problem

Quote
In file included from C:\Users\Ionut\Documents\Arduino\libraries\NewSoftSerial\NewSoftSerial.cpp:39:0:
C:\Users\Ionut\Documents\Arduino\libraries\NewSoftSerial\NewSoftSerial.h:70:16: error: conflicting return type specified for 'virtual void NewSoftSerial::write(uint8_t)'
   virtual void write(uint8_t byte);
                ^
In file included from C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/Stream.h:26:0,
                 from C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/HardwareSerial.h:29,
                 from C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/Arduino.h:223,
                 from C:\Users\Ionut\Documents\Arduino\libraries\NewSoftSerial\NewSoftSerial.cpp:37:
C:\Users\Ionut\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.6\cores\arduino/Print.h:48:20: error:   overriding 'virtual size_t Print::write(uint8_t)'
     virtual size_t write(uint8_t) = 0;

AvramIonut

PROBLEM SOLVED! I've got both NewSoftSerial and SoftwareSerial libraries. If you encounter the same issue just detele the NewSoftSerial library and the program will be compiled

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy