Go Down

Topic: VRbot Trigger word (Read 2 times) previous topic - next topic

Ummuu

Feb 24, 2011, 06:21 pm Last Edit: Apr 14, 2011, 06:44 pm by Ummuu Reason: 1
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: [Select]

#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

PaulS

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

tkbyd

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

Ummuu

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.

PaulS

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.

Go Up