]> git.piffa.net Git - arduino/blob - books/pdummies/Libraries/Adafruit_GPS/examples/locus_dumpbasic/locus_dumpbasic.pde
first commit
[arduino] / books / pdummies / Libraries / Adafruit_GPS / examples / locus_dumpbasic / locus_dumpbasic.pde
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 #include <Adafruit_GPS.h>
14 #if ARDUINO >= 100
15  #include <SoftwareSerial.h>
16 #else
17   // Older Arduino IDE requires NewSoftSerial, download from:
18   // http://arduiniana.org/libraries/newsoftserial/
19 // #include <NewSoftSerial.h>
20  // DO NOT install NewSoftSerial if using Arduino 1.0 or later!
21 #endif
22
23 // Connect the GPS Power pin to 5V
24 // Connect the GPS Ground pin to ground
25 // If using software serial (sketch example default):
26 //   Connect the GPS TX (transmit) pin to Digital 3
27 //   Connect the GPS RX (receive) pin to Digital 2
28 // If using hardware serial (e.g. Arduino Mega):
29 //   Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
30 //   Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
31
32 // If using software serial, keep these lines enabled
33 // (you can change the pin numbers to match your wiring):
34 #if ARDUINO >= 100
35   SoftwareSerial mySerial(3, 2);
36 #else
37   NewSoftSerial mySerial(3, 2);
38 #endif
39 Adafruit_GPS GPS(&mySerial);
40 // If using hardware serial (e.g. Arduino Mega), comment
41 // out the above six lines and enable this line instead:
42 //Adafruit_GPS GPS(&Serial1);
43
44 void setup()  
45 {    
46   while (!Serial);  // Leonardo will wait till serial connects
47
48   // connect at 115200 so we can read the GPS fast enuf and
49   // also spit it out
50   Serial.begin(115200);
51   Serial.println("Adafruit GPS logging start test!");
52
53   // 9600 NMEA is the default baud rate for MTK - some use 4800
54   GPS.begin(9600);
55   
56   GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
57
58   // If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
59   while (mySerial.available())
60      mySerial.read();
61
62   delay(1000);
63   GPS.sendCommand("$PMTK622,1*29");
64   Serial.println("----------------------------------------------------");
65 }
66
67
68 void loop()                     // run over and over again
69 {  
70   // If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
71   if (mySerial.available()) {
72     char c = mySerial.read();
73     if (c) {
74 #ifdef UDR0
75       UDR0 = c;  
76 #else
77       Serial.print(c);
78 #endif
79     }
80   }
81 }
82