Pages: [1]   Go Down
Author Topic: VRbot Trigger word  (Read 1675 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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
« Last Edit: April 14, 2011, 11:44:35 am by Ummuu » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46048
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know how to help you, but I would like to ask you a question. Can you explain this:
Code:
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?
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46048
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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..!!! smiley

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any Suggestions Guys???????!

The Trigger word is STILL not working... any HELP would be appreciated! smiley
Logged

New Jersey
Online Online
Faraday Member
**
Karma: 48
Posts: 3410
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
#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.
« Last Edit: April 14, 2011, 11:43:41 am by Ummuu » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Code:
NewSoftSerial tx(30, 3); //tx on 14
  NewSoftSerial rx(2, 30); //rx on 12

Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry about that.
The Code is in the box:

Code:
#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');
    }
   
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 14, 2011, 11:40:26 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for all ur useful inputs!!
Logged

Pages: [1]   Go Up
Jump to: