Go Down

Topic: Problem without usb pc port (Read 647 times) previous topic - next topic

dimitrird

#15
Jun 19, 2017, 01:48 pm Last Edit: Jun 19, 2017, 01:55 pm by dimitrird
I tried to remove bridge mode but no result, can you tell me about the code I put at the beginning what part delete exactly, thank you
Code: [Select]

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

const int out3 = 7;
const int out4 = 8;
//Groups and Commands
enum Groups
{
  GROUP_1  = 1,
};

enum Group1
{
  G1_OUVRIR = 0,
  G1_FERMER = 1,
};


int8_t group, idx;

void setup()
{
  // 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(5);

  group = GROUP_1; //lancement du groupe (customisé)

pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
// enable or disable a relay (1 to 4)
void setRelay(int relay, int value)
{
if(relay > 0 && relay < 5) digitalWrite((relay + 4), value);
}


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 = 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_1:
     switch (idx)
     {
     case G1_OUVRIR:
          digitalWrite(7, HIGH);
          digitalWrite(8, LOW);
          group = GROUP_1;
         
          break;
       case G1_FERMER:
         digitalWrite(7, LOW);
         digitalWrite(8, HIGH); setRelay(4, 1);                        // enable relay 4
Serial.print("Relay 4: Enabled ... ");
delay(10000);                           // wait for a second
setRelay(4, 0);                        // disable relay 4
Serial.println("Disabled");
delay(10000);                           // wait for a second
}
         group = GROUP_1;
         break;
         
   }
}

J-M-L

How are things plugged and jumpers configured ?

This
Code: [Select]
while (!easyvr.detect())
  {
    Serial.println("EasyVR not detected!");
    delay(1000);
  }
will block forever if easyVR is not detected and since you don't have the serial port you can't see the error message - suggests you blink the built in led in this while --> if you see it blink then you know that is your problem and that you need to probably configure something differently

('Don't have that shield so unsure)
Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums
Pas de messages privés SVP

dimitrird


In fact, it's a mass problem, I've connected a usb adapter, I have wired the metal part of the adapter to a screw on my computer and it works, what can I do to solve this problem ?

PaulS

Quote
In fact, it's a mass problem
Too much mass? Or, too little mass?
The art of getting good answers lies in asking good questions.

MorganS

It might be a mis-translation of "ground" or "earth"?
"The problem is in the code you didn't post."

dimitrird

The microphone is not grounded

MorganS

Dimitrird, this would be the perfect time for you to let us know some more details about the "mass problem."
"The problem is in the code you didn't post."

J-M-L

'Masse' in French means ground / 0V
Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums
Pas de messages privés SVP

dimitrird


dimitrird


Go Up