-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgps.ino
41 lines (34 loc) · 1.14 KB
/
gps.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// this is the code branch for GPS location tracking to calculate the final recovery distance from the launchpad
//
//ATTENTION Jamiee: GPS traccking, application, main code
//Program function:
// Location
// Distance from Launchpad
// Estimated Altitude (Cedric/Seb)
#include <TinyGPS++.h>
#include <AltSoftSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
AltSoftSerial ss(RXPin, TXPin);
void setup(){
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop(){
// Achieving values for latitude, longitude and altitude.
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()){
Serial.print("Latitude= ");
Serial.println(gps.location.lat(), 6); // Latitude in degrees
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6); // Longitude in degrees
Serial.print("Altitude= ");
Serial.println(gps.altitude.meters()); // Altitude in meters
// NEED LAUMCH PAD COORDS TO CALCULATE DISTANCE TO ROCKET
}
}
}