VRbot Trigger word

Hi,

I have started using VRbot seems like a fairly sweet product. I just can not get the trigger word to work. using the following code:

#include <SoftwareSerial.h>

//#include <NewSoftSerial.h>
 int i;
 char reader;
// NewSoftSerial tx(30,3);// tx on 14
// NewSoftSerial rx(2,30);// rx on 12 
void setup()
{
  
 pinMode(12, OUTPUT);
 Serial.begin(9600);
 Serial.begin(9600);
 Serial.begin(9600);
 delay(1000);
Serial.print('b');
for(i=0; i<100; i++){
if(Serial.read()=='o'){
Serial.println("awake");
break;
   }
delay(1);
   }//for
Serial.print('x');
for(i=0; i<100; i++){
if(Serial.read()=='x'){
Serial.println("x received");
break;
   }
delay(1);
   }//for
 Serial.print(' ');
for(i=0; i<100; i++){
if(Serial.read()=='A'){
Serial.println("firmware good");
break;
   }
delay(1);
   }//for  
  Serial.print('l');
  Serial.print('A');
for(i=0; i<100; i++){
if(Serial.read()=='o'){
Serial.println("language set");
break;
   }
delay(1);
   }//for  
  Serial.print('o');
  Serial.print('A');
for(i=0; i<100; i++){
if(Serial.read()=='o'){
Serial.println("Infinite Timeout");
break;
   }
delay(1);
   }//for 
  Serial.print('i');
  Serial.print('B');
Serial.println("trigger");
  
}//setup
void loop()
{
  reader = Serial.read();
 // Serial.println(reader);
if(reader=='s'){
  Serial.println(reader);
  delay(100);
  Serial.print(' '); 
  reset();
}//read
if(reader=='F'){
  Serial.println(reader);
  digitalWrite(12, HIGH);
  delay(200);
  digitalWrite(12, LOW);
}

if(reader=='t'){
Serial.println(reader);
reset();}
if(reader=='e'){
Serial.println(reader);
reset();}

}//loop

void reset(){
  for(i=0; i<1000; i++){
    reader = Serial.read();
    delay(1);
if(reader!=-1)
break;}
 digitalWrite(12, LOW);
 delay(100);
  Serial.print('i');
  Serial.print('B');
}

and the Trigger is JUST NOT WORKING!

Help on that will be MUCH appreciated,

Thank you

I don't know how to help you, but I would like to ask you a question. Can you explain this:

 Serial.begin(9600);
 Serial.begin(9600);
 Serial.begin(9600);

I'm not aware of any need to call the begin method more than once.

Also, why are you including SoftwareSerial.h?

Finally, you seem to be reading and writing from the serial port. What is connected to the serial port? Where is the VRbot attached?

Paul's on the right track.

Take the "include SoftwareSerial.h" out.... NewSoftSerial replaces it.

Then, before the "void setup()", you need something like....

NewSoftSerial mySerialPort(5,6erInToArdu,SerOutFrmArdu);

(You'll have to change the numbers for how you have things hooked up. The first number says which pin stuff will come in to the Arduino on, the second is the pin the Arduino will send things out on.)

THEN, probably somewhere in "setup()", you need...

mySerialPort.begin(9600);

(Keep ONE of the " Serial.begin(9600);"s if you will also be communicating with the IDE's serial monitor.)

Hi Paul,

the software serial was not working properly so what i did was used the Arduino's TX and RX pins to connect the VRbot. When i upload code to the board i detach the VRbot and reattach it to the Arduino's RX and TX
Also its baud rate was commented out and was used only once.

When i upload code to the board i detach the VRbot and reattach it to the Arduino's RX and TX

This will certainly be necessary. But, when running, it appears that the Arduino is talking to the VRBot AND the PC over the same set of pins. I suspect that that is confusing the VRbot.

actually it works PERFECTLY..........
arduino and VRBOT works fine once the code is uploaded and VRbot reattached. Its also monitored using the serial monitor and it works just fine when I do NOT use the trigger word...... if there is an Example code where the trigger word works FINE with the Arduino would REALLLLLLLLLLLLLLLLLLLY help..!!! :slight_smile:

Any Suggestions Guys???????!

The Trigger word is STILL not working... any HELP would be appreciated! :slight_smile:

I suspect that the reason no-one has responded is that you haven't acted on their earlier suggestions, where they've identified a very serious issue. Also, you really haven't given enough detail regarding what is happening, specifically, when you say that the VRBot is working perfectly, what do you mean?

Repeating what PaulS said for emphasis, the code you've posted is apparently using the arduino Serial interface to talk to the VRBot. From the sequence of VRBot commands you're sending, that is clearly your intent. However, you're also using that same interface to send commentary, presumably to a terminal program that's also attached to arduino tx. The problem is that the VRBot is receiving your debugging messages too and is trying to interpret them as commands. If you're lucky, they will make no sense to it. If you're not, you'll change something in it's configuration that will make it ignore your request to start VR. Frankly, I'm too lazy to try to figure out what the device will make of what you're sending to it, but you need to figure out another way to send progress messages back to a terminal. You were on the right track with NewSoftSerial - see if you can get that working first.

Where you are trying to read from the serial port, you can't assume that characters have arrived. Serial communication is slow; use Serial.available() to check rather than 100 attempts or delays.

Lastly, you might want to set a finite timeout in case it doesn't recognize 'Attack' in your voice/accent.

Hi,
Thank you for your input. I was busy with the hardware part of the project. Switching back to the software now and made changes to the code and finally have it working with NO trigger word.
The code is as follows:

#include <NewSoftSerial.h>

  int i;
  char reader;
  NewSoftSerial tx(30, 3); //tx on 14
  NewSoftSerial rx(2, 30); //rx on 12

void setup()
 {
   
  for(i=4; i<=13; i++)
  pinMode(i, OUTPUT);
 
   reset();
  Serial.begin(9600);
  tx.begin(9600);
  rx.begin(9600);
  delay(1000);
  
  tx.print('b');
  for(i=0; i<100; i++){
    if (rx.read()=='o'){
      Serial.println("awake");
      break;
    }
    delay(1);
  }
  tx.println('x');
  for (i=0; i<100; i++){
    if(rx.read()=='x'){
      Serial.println("x reveived");
      break;
    }
      delay(1);
  }//for
  tx.println(' ');
  for(i=0; i<100; i++){
    if(rx.read()=='A'){
    Serial.println("firmware good");
    break;
  }
  delay(1);
  }//for
   tx.print('l');
   tx.println('A');
   for (i=0; i<100; i++){
   if(rx.read()=='o'){
    Serial.println("language set");
    break;
   }
   delay(1);
   }//for
 
  tx.print('o');
  tx.println('A');  
  for (i=0; i<100; i++){
   if(rx.read()=='o'){
   
     Serial.println("Infinite Timeout");
     break;
   }
   delay(1);
  }//for
  tx.print('i');
  tx.println('D');
 Serial.println("Wordset 3");
 
  }//setup
 
 void loop()
 {
  reader = rx.read();
 if(reader=='s'){
  delay(100);
 tx.print(' ');
 }//read

  if(reader=='B'){
   reset();
   digitalWrite(4, HIGH);
  }
   if(reader=='C'){
   reset();
   digitalWrite(5, HIGH);
 //  delay(100);  
  }

   if(reader=='D'){
   reset();
   digitalWrite(6, HIGH);
    }

   if(reader=='E'){
   reset();
   digitalWrite(7, HIGH);
    }
    
   if(reader=='F'){
   reset();
   digitalWrite(8, HIGH);
    }
   if(reader=='G'){
   reset();
   digitalWrite(9, HIGH);
    }
    
   if(reader=='H'){
   reset();
   digitalWrite(10, HIGH);
    }
    
   if(reader=='I'){
   reset();
   digitalWrite(11, HIGH);
    }
   if(reader=='J'){
   reset();
   digitalWrite(12, HIGH);
    }
   if(reader=='K'){
   reset();
   digitalWrite(13, HIGH);
    }
    
    if(reader=='t')
    reset();
    if(reader=='e')
    reset();
 }
    void reset() {
      for(i=4; i<=13; i++)
      digitalWrite(i, LOW);
      delay(100);
      tx.print('i');
      tx.println('D');
    }

it works perfect. I need HELP with using a trigger word.
Lets say I want the trigger word to be "MAX" and after that say either the already existing group set (e.g. in this case "word set 3" 1, 2, 33...etc.) OR specify a NEW group (e.g. Group 1 consisting of words GRAB, RELEASE, FORWARD, BACK)

Please help me with this i will REALLY appreciate it!

Thank you.

We'd really appreciate it if you posted code in a code box - use the # icon on the editor's toolbar - to save our aching scrolling fingers.

Comments would be good too, but what do these mean?

NewSoftSerial tx(30, 3); //tx on 14
  NewSoftSerial rx(2, 30); //rx on 12

Sorry about that.
The Code is in the box:

#include <NewSoftSerial.h>

  int i;
  char reader;
  NewSoftSerial tx(30, 3); //tx on 14
  NewSoftSerial rx(2, 30); //rx on 12

void setup()
 {
   
  for(i=4; i<=13; i++)
  pinMode(i, OUTPUT);
 
   reset();
  Serial.begin(9600);
  tx.begin(9600);
  rx.begin(9600);
  delay(1000);
  
  tx.print('b');
  for(i=0; i<100; i++){
    if (rx.read()=='o'){
      Serial.println("awake");
      break;
    }
    delay(1);
  }
  tx.println('x');
  for (i=0; i<100; i++){
    if(rx.read()=='x'){
      Serial.println("x reveived");
      break;
    }
      delay(1);
  }//for
  tx.println(' ');
  for(i=0; i<100; i++){
    if(rx.read()=='A'){
    Serial.println("firmware good");
    break;
  }
  delay(1);
  }//for
   tx.print('l');
   tx.println('A');
   for (i=0; i<100; i++){
   if(rx.read()=='o'){
    Serial.println("language set");
    break;
   }
   delay(1);
   }//for
 
  tx.print('o');
  tx.println('A');  
  for (i=0; i<100; i++){
   if(rx.read()=='o'){
   
     Serial.println("Infinite Timeout");
     break;
   }
   delay(1);
  }//for
  tx.print('i');
  tx.println('D');
 Serial.println("Wordset 3");
 
  }//setup
 
 void loop()
 {
  reader = rx.read();
 if(reader=='s'){
  delay(100);
 tx.print(' ');
 }//read

  if(reader=='B'){
   reset();
   digitalWrite(4, HIGH);
  }
   if(reader=='C'){
   reset();
   digitalWrite(5, HIGH);
 //  delay(100);  
  }

   if(reader=='D'){
   reset();
   digitalWrite(6, HIGH);
    }

   if(reader=='E'){
   reset();
   digitalWrite(7, HIGH);
    }
    
   if(reader=='F'){
   reset();
   digitalWrite(8, HIGH);
    }
   if(reader=='G'){
   reset();
   digitalWrite(9, HIGH);
    }
    
   if(reader=='H'){
   reset();
   digitalWrite(10, HIGH);
    }
    
   if(reader=='I'){
   reset();
   digitalWrite(11, HIGH);
    }
   if(reader=='J'){
   reset();
   digitalWrite(12, HIGH);
    }
   if(reader=='K'){
   reset();
   digitalWrite(13, HIGH);
    }
    
    if(reader=='t')
    reset();
    if(reader=='e')
    reset();
 }
    void reset() {
      for(i=4; i<=13; i++)
      digitalWrite(i, LOW);
      delay(100);
      tx.print('i');
      tx.println('D');
    }

And the comments?

BTW, you can edit earlier posts by clicking on "Modify", highlighting the code, then clicking on the # icon (hint)

Another useful tool in the IDE is auto-format (ctrl-T) which makes a reasonable job of sorting out obscure indentation.

Thank you for all ur useful inputs!!