This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMobileRobot_GPS.ino
74 lines (66 loc) · 1.98 KB
/
MobileRobot_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <SoftwareSerial.h>
#include <TinyGPS.h>
TinyGPS gps;
SoftwareSerial serialgps(2, 3); // RX, Tx
int year;
byte month, day, hour, minute, second, hundredths;
unsigned long chars;
unsigned short sentences, failed_checksum;
float latitude, longitude;
int contLocalizacao = 0;
void send_data();
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
delay(5);
}
void loop()
{
sequenciaGPS();
delay(10);
}
void sequenciaGPS()
{
while (Serial1.available())
{
int c = Serial1.read();
if (gps.encode(c))
{
gps.f_get_position(&latitude, &longitude);
send_data();
/*
Serial.print("Lat/Long: ");
Serial.print(latitude, 5);
Serial.print(",");
Serial.println(longitude, 5);
gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths);
Serial.print("Date: "); Serial.print(month, DEC); Serial.print("/");
Serial.print(day, DEC); Serial.print("/"); Serial.print(year);
Serial.print(" Time: "); Serial.print(hour, DEC); Serial.print(":");
Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC);
Serial.print("."); Serial.println(hundredths, DEC);
Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude());
Serial.print("Course (degrees): "); Serial.println(gps.f_course());
Serial.print("Speed(kmph): "); Serial.println(gps.f_speed_kmph());
Serial.print("Satellites: "); Serial.println(gps.satellites());
Serial.println();
gps.stats(&chars, &sentences, &failed_checksum);
*/
}
}
}
/********************************************/
/* Sand Data */
/********************************************/
void send_data()
{
String dataGPS = "#";
dataGPS += String(latitude, 5);
dataGPS += "|";
dataGPS += String(longitude, 5);
dataGPS += "|";
Serial2.print(dataGPS);
}
/********************************************/