init ci
This commit is contained in:
commit
c89402522c
41
GPXTracker.ino
Normal file
41
GPXTracker.ino
Normal file
@ -0,0 +1,41 @@
|
||||
#include <TinyGPS++.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
#define BUFFER_SIZE 256
|
||||
#define SERIAL_TX_PIN 4
|
||||
#define SERIAL_RX_PIN 5
|
||||
|
||||
TinyGPSPlus gps;
|
||||
SoftwareSerial serialGPS(SERIAL_RX_PIN, SERIAL_TX_PIN);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
serialGPS.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("Running loop...");
|
||||
while (serialGPS.available() > 0) {
|
||||
Serial.println("GPS data available");
|
||||
if (gps.encode(serialGPS.read())) {
|
||||
Serial.println("GPS data read");
|
||||
if (gps.location.isValid()) {
|
||||
Serial.println("GPS location valid");
|
||||
float latitude = gps.location.lat();
|
||||
String latitudeStr = String(latitude , 6);
|
||||
float longitude = gps.location.lng();
|
||||
String longitudeStr = String(longitude , 6);
|
||||
|
||||
Serial.print("Lat: ");
|
||||
Serial.print(latitudeStr);
|
||||
Serial.print(" Lon: ");
|
||||
Serial.println(longitudeStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(500);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user