A simple example of using a MTK3339 GPS module on an adafruit or sparkfun shield installed on a Multitech UDK developer board.

Dependencies:   SerialGPS-SoftSerial SoftSerial

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "SoftSerial.h"
00002 #include "SerialGPS.h"
00003 //#include "GPSPARSER.h"
00004 
00005 Serial pc(USBTX, USBRX);
00006 
00007 int main(void)
00008 {
00009     pc.baud(115200);
00010 #ifdef DEMO_ONLY
00011     SoftSerial *softUART = new SoftSerial(D6, D7);
00012     softUART->baud(9600);
00013     softUART->puts("Hello\r\n");
00014     while(true){
00015         int c = softUART->getc();
00016         softUART->putc(c);
00017     }
00018 #endif
00019     DigitalOut led(D0);
00020     SerialGPS gps(D6, D7, 9600);
00021     
00022     while(true){
00023         if(gps.sample() > 0){
00024             pc.printf("Last longitude degrees were... %f\r\n", gps.longitude);
00025             pc.printf("Last latitude degrees were... %f\r\n", gps.latitude);
00026             led = true;
00027         } else {
00028             pc.printf("No lock\r\n");
00029             led = false;
00030         }
00031         wait(5);
00032     }
00033     
00034     return 0;
00035 }