]> git.piffa.net Git - arduino/blob - books/pdummies/Libraries/Adafruit_GPS/examples/leo_locus_start/leo_locus_start.ino
first commit
[arduino] / books / pdummies / Libraries / Adafruit_GPS / examples / leo_locus_start / leo_locus_start.ino
1 // Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
2 //
3 // This code turns on the LOCUS built-in datalogger. The datalogger
4 // turns off when power is lost, so you MUST turn it on every time
5 // you want to use it!
6 //
7 // Tested and works great with the Adafruit Ultimate GPS module
8 // using MTK33x9 chipset
9 //    ------> http://www.adafruit.com/products/746
10 // Pick one up today at the Adafruit electronics shop 
11 // and help support open source hardware & software! -ada
12 //This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
13
14 #include <Adafruit_GPS.h>
15 #include <SoftwareSerial.h>
16
17 // Connect the GPS Power pin to 5V
18 // Connect the GPS Ground pin to ground
19 // If using software serial (sketch example default):
20 //   Connect the GPS TX (transmit) pin to Digital 8
21 //   Connect the GPS RX (receive) pin to Digital 7
22 // If using hardware serial:
23 //   Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
24 //   Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
25
26 // If using software serial, keep these lines enabled
27 // (you can change the pin numbers to match your wiring):
28 //SoftwareSerial mySerial(8, 7);
29 //Adafruit_GPS GPS(&mySerial);
30
31 // If using hardware serial, comment
32 // out the above two lines and enable these two lines instead:
33 Adafruit_GPS GPS(&Serial1);
34 HardwareSerial mySerial = Serial1;
35
36 // Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
37 // Set to 'true' if you want to debug and listen to the raw GPS sentences
38 #define GPSECHO  true
39
40 void setup()  
41 {    
42   // connect at 115200 so we can read the GPS fast enuf and
43   // also spit it out
44   Serial.begin(115200);
45   delay(2000);
46   Serial.println("Adafruit GPS logging start test!");
47
48   // 9600 NMEA is the default baud rate for MTK - some use 4800
49   GPS.begin(9600);
50   
51   // You can adjust which sentences to have the module emit, below
52   // Default is RMC + GGA
53   GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
54   // Default is 1 Hz update rate
55   GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
56
57   delay(500);
58   Serial.print("\nSTARTING LOGGING....");
59   if (GPS.LOCUS_StartLogger())
60     Serial.println(" STARTED!");
61   else
62     Serial.println(" no response :(");
63   delay(1000);
64 }
65
66 void loop()                     // run over and over again
67 {
68   char c = GPS.read();
69   // if you want to debug, this is a good time to do it!
70   if ((c) && (GPSECHO))
71     Serial.write(c);  
72 }
73