Trouble with Parallex GPS and Arduino Mega2560

Hey. So I just recently bought a Parallax GPS and and Arduino Mega2560 to do one of my projects. Right now I am trying to get the basic GPS readout from the serial monitor. However when I run the code I am using, all I get on the serial monitor is just the letter "y" repeated. Does anyone have a clue what might be going on? Any help is appreciated. I am using the simple code below:

#include <SoftwareSerial.h>

SoftwareSerial GPS=SoftwareSerial(1,0);
void setup()
{
GPS.begin(4800);
Serial.begin(9600);
}
void loop(){
Serial.write(GPS.read());
}

You can't use SoftwareSerial on pins 0 and 1 when you are using those for hardware Serial. Try pins 2 and 3.

So I switched pins so my code reads:
SoftwareSerial GPS = SoftwareSerial (2,3)

but it still comes up with a repeated "y" in the serial monitor. Should I use another command besides the SoftwareSerial function? Maybe something like a hardware interface function. I'm open to any ideas.

Maybe tell us which Parallax GPS you're using?

Is the convention with Software Serial that different from using the UART?
I successfully wrote a programme recently to read a GPS and store the results in an array.
I think that you have to check for Serial.available each time?
id est:

  while (serial_idx < 13)  // loop - capture hhmmss bytes
                           // GPSchar[07]..[12]
  {
    if(Serial.available() > 0)   //  ! ! !
    {
      GPSchar[serial_idx] = Serial.read();
      serial_idx++;
    }
  }

The Parallex GPS is the PMB-688

Same as mine (Parallax).

So, you reckon that

void setup()
{
  GPS.begin(4800);
  Serial.begin(9600);
}
void loop()
{
  Serial.write(GPS.read());
}

ought to result what precisely?

So I switched pins so my code reads:
SoftwareSerial GPS = SoftwareSerial (2,3)

You've got 4 hardware serial ports. Please explain why you are using software serial ports at all!

chrispy4800:
still comes up with a repeated "y" in the serial monitor.

GPS.read() will return -1 if no characters are available to read. When that it sent to Serial Monitor it is displayed as character 255 (ÿ).

int value = GPS.read();
if (value != -1)
    Serial.write((char)value);

So that's what that character was. That makes sense then. The whole point behind this simple code was to see if I could get the gps data to appear on my serial monitor. It was a simple test before I got into more complex coding. This simple code actually comes from watching a youtube video at this link - YouTube. I'm a beginner at this and I knew that this arduino has hardware ports. If the easier route is to use those, then could someone briefly tell me how? Thanks.

If the easier route is to use those, then could someone briefly tell me how? Thanks.

Connect the GPS to RX1 and TX1, then use Serial1 to communicate with it.

So then would the code look simply like this if i was using a gps that was 4800 bps?

void setup()

{
  Serial1.begin(4800);
}
void loop(){
  Serial1.write(Serial1.read());
}

If you are only going to use one serial port, why not use Serial? I thought you want to read from the GPS and print/write to the PC.

If you are getting ASCII data from the GPS, why are you sending binary data? Why are you sending the GPS data back to the GPS? It already knows what it sent.

I do want to read from the GPS and print/write to the PC. I'm a complete novice at stuff like this and I was just following an example. I guess I am just confused on how to write the code to complete such a task.

You have 4 "phones" labeled Serial, Serial1, Serial2, and Serial3. You want the GPS to call you on one "phone" and you want to talk to the PC on another "phone".

The only "phone" that can talk to the serial port on the PC is the one labeled Serial.

It really isn't rocket surgery to figure out what "phone" the GPS has to be connected to, pin wise, and what "phone" you use to talk to it.

I wrote this for use with a 328P - GPS output to D0. I think it'll work with your Mega, too. (If the Megas don't have the D13 LED then you can comment those lines out.)
My only interest was the RMC sentence, specifically the time characters.
The following captures the time characters, and knocks the seconds characters back out to Serial Monitor.
Kindly let me know how you fare.

// serialexper05
// trying to trigger event resulting from successful
// capture of $GPRMC header
// trying to capture seconds  i.e. -- bytes 11,12
// and print them out  works  03/08/2012

byte serial_idx;
byte GPSchar [13];
byte GPSchk [7] = {36,71,80,82,77,67,44};
//                 $  G  P  R  M  C  ,

void setup()
{
  Serial.begin(4800);
  pinMode(13, OUTPUT);
}

void loop()               // wait for $GPRMC,
{
  while (serial_idx < 7)
  {  
    if(Serial.available() > 0)
    {
      GPSchar[serial_idx] = Serial.read();
      if(GPSchar[serial_idx] == GPSchk[serial_idx])
      {
        serial_idx++;
      }
      else
      {
        serial_idx = 0;   // 
      }
    }
  }
  while (serial_idx < 13)  // loop - capture hhmmss bytes
                           // GPSchar[07]..[12]
  {
    if(Serial.available() > 0)
    {
      GPSchar[serial_idx] = Serial.read();
      serial_idx++;
    }
  }
  successblink();
}
 
void successblink()      //  may leave unused
{
  digitalWrite(13, HIGH);
  delay(75);
  digitalWrite(13, LOW);
  Serial.print(GPSchar[11],DEC);
  Serial.print("  ");
  Serial.println(GPSchar[12],DEC);
  for (int ax=0; ax<13; ax++) //clear GPSchar array
  {
    GPSchar[ax]=0;
  }
  serial_idx = 0;
}

Adding link ? http://arduino.cc/forum/index.php/topic,95285.0.html

So I've tried your code, and other codes, and nothing really seems to be working. At some points it seems like the above code is working because LED 13 is blinking, but whenever I pull up the serial monitor, LED 13 goes solid and nothing appears on the serial monitor. In general, the GPS LED is a solid red but whenever I try to get information out of it, it always fails. I'm at a lost at what to do. It might be a problem with the GPS TX cable or with something in the software. Does anyone have any suggestions?

It might be a problem with the GPS TX cable or with something in the software. Does anyone have any suggestions?

Or, it might be that you don't have it connected to your Mega correctly, or it could be that you haven't shared YOUR code.

Post some pictures and code.

My only connections are GPS output [yellow wire from its supplied lead dress] to Arduino "D0" (and, of course, their Ground/common together.) Is D0 = RX on the Mega, too?

When I power up the arduino without the serial monitor it still goes, but when I push the Serial Monitor button in the IDE it resets the arduino, and then it's off to the races (data out each second).

And I do not have the GPS input (its blue wire) connected to D1.

I set it up again here on the bench, before posting just now, and it runs along without a hitch. One thing is, though, the output is the Decimal value of the ASCII code for the seconds digits (e.g. "48 48" for secs = 00, "48 57" for secs = 09).

*** The Arduino is running off the USB but the GPS is on a separate 5V. ***