]> git.piffa.net Git - arduino/blob - books/pdummies/Libraries/Adafruit_GPS/examples/leo_locus_dumpbasic/leo_locus_dumpbasic.ino
first commit
[arduino] / books / pdummies / Libraries / Adafruit_GPS / examples / leo_locus_dumpbasic / leo_locus_dumpbasic.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
13 //This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
14
15 #include <Adafruit_GPS.h>
16 #include <SoftwareSerial.h>
17
18 // Connect the GPS Power pin to 5V
19 // Connect the GPS Ground pin to ground
20 // If using software serial (sketch example default):
21 //   Connect the GPS TX (transmit) pin to Digital 8
22 //   Connect the GPS RX (receive) pin to Digital 7
23 // If using hardware serial:
24 //   Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
25 //   Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
26
27 // If using software serial, keep these lines enabled
28 // (you can change the pin numbers to match your wiring):
29 //SoftwareSerial mySerial(8, 7);
30 //Adafruit_GPS GPS(&mySerial);
31
32 // If using hardware serial, comment
33 // out the above two lines and enable these two lines instead:
34 Adafruit_GPS GPS(&Serial1);
35 HardwareSerial mySerial = Serial1;
36
37 void setup()  
38 {    
39   // connect at 115200 so we can read the GPS fast enuf and
40   // also spit it out
41   Serial.begin(115200);
42   delay(2000);
43   Serial.println("Adafruit GPS logging start test!");
44
45   // 9600 NMEA is the default baud rate for MTK - some use 4800
46   GPS.begin(9600);
47   
48   GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
49
50   while (mySerial.available())
51      mySerial.read();
52
53   delay(1000);
54   GPS.sendCommand("$PMTK622,1*29");
55   Serial.println("----------------------------------------------------");
56 }
57
58
59 void loop()                     // run over and over again
60 {  
61   if (mySerial.available()) {
62     Serial.write(mySerial.read());  
63   }
64 }
65