GPS clock

i am a new user to arduino and am making a clock that gets time from an old tripmate GPS and displays the time on some 12" seven segment displays. Is it possible to decode the NMEA strings from the gps and store the time into a variable so it could be displayed? a string would look like this
$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,071281,003.1,W*43

and 123519 would be the time (12:35:19)

if it is possible, can some one give some example code?

I've done this before on different chips. The strategy is basically that you have to keep reading the serial port, and when you see an "R", you check for an "M", and if that's true, you check for a "C", and if that's true you check for a comma (so you have checked for the string "RMC," ). If these checks are true, you know the next values in the serial buffer will be the time, which comes right after it.

Here's a <> as to how you might start to do this on the Arduino, You'll need to figure out the escape character for the comma than comes between $GPRMC and the time. You also have to make sure that the RS-232 from the GPS unit is not inverted and that it's in 5V form. Usually a Maxim MAX232 chip will do the trick.

This code is just a guess... it's not going to work, but it might be a start. You may want to throw in some Serial.println commands for the serial monitor, so that you can see what's being stored in variables.

D


void loop () {
// read the serial port
serbyte = Serial.read();

// if the input is '-1' then there is no data
// at the input, otherwise store it
if (serbyte != -1) {
val = serbyte;
}

if (val == 'R') {
val = Serial.read();
if (val == 'M') {
val = Serial.read();
if (val == 'C') {
val = Serial.read();
if (val == ''') { // this might not be the right way to define a comma!

// capture the time into variables here.

}
}
}
}
delay(10);
}

if (val == ''') { // this might not be the right way to define a comma!

No, you compared val with a single quote. I guess you should just write
if (val == ',') {

If you want to check for a comma.

regex for arduino would be GREAT :smiley:

How would i capture those variables?