1 #include <Adafruit_GPS.h>
2 #include <SoftwareSerial.h>
3 Adafruit_GPS GPS(&Serial1);
5 // Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
6 // Set to 'true' if you want to debug and listen to the raw GPS sentences
9 // this keeps track of whether we're using the interrupt
11 boolean usingInterrupt = false;
16 // connect at 115200 so we can read the GPS fast enuf and
19 Serial.println("Adafruit GPS logging start test!");
21 // 9600 NMEA is the default baud rate for MTK - some use 4800
24 // You can adjust which sentences to have the module emit, below
25 // Default is RMC + GGA
26 GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
27 // Default is 1 Hz update rate
28 GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
30 // the nice thing about this code is you can have a timer0 interrupt go off
31 // every 1 millisecond, and read data from the GPS for you. that makes the
32 // loop code a heck of a lot easier!
37 Serial.print("Starting logging....");
38 if (GPS.LOCUS_StartLogger()) {
39 Serial.println(" STARTED!");
42 Serial.println(" no response :(");
49 void loop() // run over and over again
52 digitalWrite(7, HIGH);
58 /******************************************************************/
59 // Interrupt is called once a millisecond, looks for any new GPS data, and stores it
60 SIGNAL(TIMER0_COMPA_vect) {
62 // if you want to debug, this is a good time to do it!
64 if (c) Serial.print(c);
67 void useInterrupt(boolean v) {
69 // Timer0 is already used for millis() - we'll just interrupt somewhere
70 // in the middle and call the "Compare A" function above
72 TIMSK0 |= _BV(OCIE0A);
73 usingInterrupt = true;
75 // do not call the interrupt function COMPA anymore
76 TIMSK0 &= ~_BV(OCIE0A);
77 usingInterrupt = false;