-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcdgpsmotor.ino
121 lines (75 loc) · 1.72 KB
/
lcdgpsmotor.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
TinyGPS gps;
SoftwareSerial ss(5,4);
#define enB 3
#define in3 2
#define in4 13
const int rs = 12, en = 11, d4 =10 , d5 = 9, d6 = 8, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int i;
float lat, lng;
static char lat1[8];
static char lng1[8];
void setup()
{
Serial.begin(9600);
ss.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Boat No - 1127");
lcd.setCursor(0,1);
lcd.print(" GPS Location");
delay(5000);
lcd.noDisplay();
pinMode(enB, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
void loop()
{
B:
lcd.display();
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (ss.available())
{
char c = ss.read();
if (gps.encode(c))
newData = true;
}
}
if (newData)
{
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
lcd.setCursor (0,0);
lcd.print("LAT = ");
lcd.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("LON = ");
lcd.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
lcd.print(" ");
lat = flat;
lng = flon;
}
dtostrf(lat,7, 6, lat1);
dtostrf(lng,7, 6, lng1);
analogWrite(enB, 0); // zero speed
delay(5000);
analogWrite(enB, 100); // medium speed
delay(5000);
analogWrite(enB, 255); // High Speed
delay(5000);
analogWrite(enB, 0); // Zero Speed
delay(5000);
}