Communication between Arduino uno and FlyPort

I just tell to check if my code is correct or wrong. Because I am new to arduino. Otherwise, servo motor connected to Flyport is not working.

EasyVR connected to Arduino is working but I want Arduino to connect to FlyPort as my main module is FlyPort. So when I connected EasyVR to Arduino and Arduino to FlyPort, its not working.

Please help me and Thanks

You have the flyport serial link defined as using pins 0 and 1. This will conflict with the built in serial port which uses the same pins. You may also have a problem if you fix that because only one SoftwareSerial link can be active at a time as they all share the same buffer. SoftwareSerial has a listen method which can help with this but it may be complicated to use.

Really? But my friend said can use SoftwareSerial to connect Arduino to Flyport.

Is there other way to solve problem?

What pins did your friend suggest that you use ?

UKHeliBob: You have the flyport serial link defined as using pins 0 and 1. This will conflict with the built in serial port which uses the same pins.

UKHeliBob speaks the truth. Why not listen? Why are you using pins 0 and 1 for SoftwareSerial when you can use hardware serial?

cloudystrife: Below is my program.

Serial.begin(9600);
 easyVR.begin(9600);
 flyport.begin(9600);

Serial uses pins 0 and 1. And you are using pins 0 and 1 for flyport as well. Do you see a problem here?

I see. My friend said pin 0 and pin 1. Sorry. I go change pin numbers.

I change to SoftwareSerial flyport(4,5). is it ok?

Still not working even though I changed pin numbers. Is there any wrong with my code?

What code? See reply #18.

Sorry. I thought I already posted.

#include <SoftwareSerial.h>

int i;
 char reader;
 SoftwareSerial easyVR(2,3);// rx, tx for easyvr
 SoftwareSerial flyport(4,5);// rx, tx for flyport
 
 
void setup()
{
 Serial.begin(9600);
 easyVR.begin(9600);
 flyport.begin(9600);
 delay(1000);
easyVR.print('b');
for(i=0; i<100; i++){
if(easyVR.read()=='o'){
Serial.println("awake");
break;
   }
delay(1);
   }//for
easyVR.print('x');
for(i=0; i<100; i++){
if(easyVR.read()=='x'){
Serial.println("x received");
break;
   }
delay(1);
   }//for
 easyVR.print(' ');
for(i=0; i<100; i++){
if(easyVR.read()=='A'){
Serial.println("firmware good");
break;
   }
delay(1);
   }//for  
  easyVR.print('l');
  easyVR.print('A');
for(i=0; i<100; i++){
if(easyVR.read()=='o'){
Serial.println("language set");
break;
   }
delay(1);
   }//for  
  easyVR.print('o');
  easyVR.print('A');
for(i=0; i<100; i++){
if(easyVR.read()=='o'){
Serial.println("Infinite Timeout");
break;
   }
delay(1);
   }//for 
  easyVR.print('i');
  easyVR.print('B');
Serial.println("trigger");
  
}//setup
void loop()
{
    reader = easyVR.read();
   // Serial.println(reader);
    if(reader=='s')
    {
      Serial.println(reader);
      delay(100);
      easyVR.print(' '); 
      reset();
    }
    ////// put if code here
    
    if(reader== 'H')                 //hello
    {               
      Serial.println(reader);
      flyport.print('z');          //send to flyport
      
    }
    
   if(reader=='t')
   {
    Serial.println(reader);
    reset();
   }
   if(reader=='e')
   {
    Serial.println(reader);
    reset();
   }

}//loop
void reset(){
  for(i=0; i<1000; i++){
    reader = easyVR.read();
    delay(1);
if(reader!=-1)
break;}
 delay(100);
  easyVR.print('i');
  easyVR.print('B');
}

It's hard to know where to start. Here, maybe:

http://www.gammon.com.au/serial

Hi,

The link you posted - There is no answer to solve my problem. Please help me to see what is wrong with my code(see reply #29).

Thanks.

Fix your code formatting first and repost it. Put each '{' and '}' on their own lines and click Tools > Auto Format.

for(i=0; i<100; i++){
if(easyVR.read()=='o'){
Serial.println("awake");
break;
   }

Your formatting needs work. See what Arrch said above.

You are reading without checking if anything is available first. Why you are reading 100 times is a mystery.

There is no answer to solve my problem.

Perhaps, but it will help improve your technique.

Hi,
I already click auto format.

#include <Servo.h>

#include <SoftwareSerial.h>

int i;
char reader;
SoftwareSerial easyVR(2,3);// rx, tx for easyvr
SoftwareSerial flyport(4,5);// rx, tx for flyport


void setup()
{
  Serial.begin(9600);
  easyVR.begin(9600);
  flyport.begin(9600);
  delay(1000);
  easyVR.print('b');
  for(i=0; i<100; i++){
    if(easyVR.read()=='o'){
      Serial.println("awake");
      break;
    }
    delay(1);
  }//for
  easyVR.print('x');
  for(i=0; i<100; i++){
    if(easyVR.read()=='x'){
      Serial.println("x received");
      break;
    }
    delay(1);
  }//for
  easyVR.print(' ');
  for(i=0; i<100; i++){
    if(easyVR.read()=='A'){
      Serial.println("firmware good");
      break;
    }
    delay(1);
  }//for  
  easyVR.print('l');
  easyVR.print('A');
  for(i=0; i<100; i++){
    if(easyVR.read()=='o'){
      Serial.println("language set");
      break;
    }
    delay(1);
  }//for  
  easyVR.print('o');
  easyVR.print('A');
  for(i=0; i<100; i++){
    if(easyVR.read()=='o'){
      Serial.println("Infinite Timeout");
      break;
    }
    delay(1);
  }//for 
  easyVR.print('i');
  easyVR.print('B');
  Serial.println("trigger");

}//setup
void loop()
{
  reader = easyVR.read();
  // Serial.println(reader);
  if(reader=='s')
  {
    Serial.println(reader);
    delay(100);
    easyVR.print(' '); 
    reset();
  }
  ////// put if code here

  if(reader== 'H')                 //hello
  {               
    Serial.println(reader);
    flyport.print('z');          //send to flyport

  }

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

}//loop
void reset(){
  for(i=0; i<1000; i++){
    reader = easyVR.read();
    delay(1);
    if(reader!=-1)
      break;
  }
  delay(100);
  easyVR.print('i');
  easyVR.print('B');
}

I have been trying many times but to no avail even though my friends helped me. It seems this is difficult to send to Flyport when I say “hello” to easyvr in arduino.

Why are you reading from the easyvr 100 times looking for a single letter?

What do you mean that I am reading from easyvr?

cloudystrife:
What do you mean that I am reading from easyvr?

for(i=0; i<100; i++){
    if(easyVR.read()=='o'){

And other places. You’re reading characters from the easyVR 100 times, whether there is serial information available or not. I can’t figure out why.

Oh. Its because of easyvr datasheet. Thus, I have to follow its datasheet. So no need this 'o'?

What datasheet?