Arduino Two Port Receive

Hey,

I have a problem with the arduino project.

I using HC11 (transmitter) and GPS Module on my project and. The receiver and the GPS Module are connect to the same arduino (I am using Arduino UNO). I want that when I get some data, the GPS Module start to act.
I succeeded to operate the GPS separately and the HC11 separately. But when I want to operate them together I dont succeed because Arduino UNO is not support more than one serial communication.
I succeed to get data from the Receiver but not from the GPS.
Thanks for helpers.
Here is the code :

#include <SoftwareSerial.h> 
#include "TinyGPS++.h"




TinyGPSPlus gps;
SoftwareSerial SoftSerial(2, 3);
SoftwareSerial HC11(5,4);




void setup() {   
 Serial.begin(9600);
 while (!Serial) {
 }


 SoftSerial.begin(9600);
 HC11.begin(9600);


}


void loop() {
 char x;
 int y;
 
 HC11.listen();
if (HC11.available()) 
{
 x=HC11.read();
 Serial.write("The number is ");
 Serial.write(x);
 Keycheck(x);
}
}
void Keycheck (int x)
{
 if (x == 49) {
 GPS_unit();
 delay(100);
 HC11.end();
}
}


void GPS_unit ()
{
 SoftSerial.listen();
 if (SoftSerial.isListening()) {
   Serial.write("\n");
   Serial.write("Yes");
 }
 else
 {
   Serial.write("\n");
   Serial.write("No");
 }
 Serial.write("\n");
 Serial.write("Starting GPS Unit"); 
 SoftSerial.listen();
 while (SoftSerial.available() > 0)
 gps.encode(SoftSerial.read());
 
 if (gps.location.isUpdated())
 {
   Serial.print("LAT="); Serial.print(gps.location.lat(), 6);
   Serial.print("  LNG="); Serial.println(gps.location.lng(), 6);
   HC11.print("LNG");
   HC11.print(gps.location.lng(), 6);
   HC11.print('\n');
    HC11.print("LAT");
   HC11.print(gps.location.lat(), 6);
   HC11.print('\n');
   delay(1000);
 }
}

LOhayon:
Here is the code (Sorry I dont know how to post it) :

Seriously? Look at the top 3 sticky posts at the beginning of the forum. If you had read Read this before posting a programming question ... and looked at item #6, you would see how to properly post your code.

Lucky for you, you can go back and edit your post and fix it.

You need to use

<softwareserial_port>.listen()

in order switch between software serial ports.

To put your code in a code box, use the </> icon in the far left of the post tool bar and paste your code between the two bracket sets that appear.

To go back and put your code in a code box, in the bottom right of your post, select “more” and click modify. When the modify post opens, high light your code and click the </> in the far left of the post tool bar. This will put you code in code brackets. Then save the changes.

It's not really practical to use more than one instance of SoftwareSerial.

If you want to connect to two serial devices life will be much simpler if you use a Mega which has 3 spare hardware serial ports.

...R

blh64:
Seriously? Look at the top 3 sticky posts at the beginning of the forum. If you had read Read this before posting a programming question … and looked at item #6, you would see how to properly post your code.

Lucky for you, you can go back and edit your post and fix it.

Thank you/

Power_Broker:
You need to use

<softwareserial_port>.listen()

in order switch between software serial ports.

Hey,
I used that but it is not working. I think that impossible with arudino uno.
There is maybe an another way?