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