/*
Exercise 6: Interface with a GPS
Your challenge is to communicate with an NMEA GPS. Some code has already been
written to get one line of information; you need to parse that information and turn
it into a latitude/longitude coordinate (preferably in decimal degrees).
(Yes, it prints the same line every time, I didn't have enough time to write this)
*/
int count = 0;
void setup() {
Serial.begin(9600);
Serial1.begin(4800); // Serial1 is connected to the custom chip
Serial1.write("G");
int count = 0;
Serial.println("Data received from UART chip:");
}
void loop() {
Serial1.write("G");
while (Serial1.available()) {
char text = Serial1.read();
if (text == ','){
count += 1;
}
if (count == 1 && text != ','){
Serial.print(text);
}else if (count == 1 && text == ','){
Serial.print("(");
}else if (count == 2 && text == ','){
Serial.print(", ");
}else if (count == 4 && text != ','){
Serial.print(text);
}else if (count == 5 && text == ','){
Serial.print(")");
Serial.println("");
}else if (count == 14){
count = 0;
}
}
delayMicroseconds(1000);
}