Hello everyone!
I am almost a beginner in Arduino / UNO.
A friend helped me a lot in building the code I'm going to post.
Basically it works perfectly, but since I need to put more "coordinates" (latitude and longitude). I will try to be as clear as possible, I apologize in advance, because I do not understand well about C / Arduino programming.
Code working perfectly with floats in the Arduino's own memory (I believe it is Flash memory).
1 - GPS code:
====================================
#include <SoftwareSerial.h>
#include <TinyGPS.h>
// Serial GPS RX e TX
SoftwareSerial ss(5, 6);
TinyGPS gps;
// aprox 100m
float margem = 0.0010000;
float latmax;
float latmin;
float longmax;
float longmin;
float tracklat[] = {-14.8540023, -14.8537225, -14.8523179, -14.8513175, -14.8509654, -14.8497273, -14.8489098, -14.8490814};
float tracklong[] = {-40.8368401, -40.8367495, -40.8363290, -40.8360174, -40.8358995, -40.8355745, -40.8355944, -40.8356088};
int tracksize = 8;
int led = 8;
void setup() {
Serial.begin(9600);
ss.begin(9600);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop() {
bool newdata = false;
unsigned long start = millis();
// Every 5 seconds we print an update
while (millis() - start < 5000) {
if (ss.available()) {
char c = ss.read();
// Serial.print(c); // uncomment to see raw GPS data
if (gps.encode(c)) {
newdata = true;
// break; // uncomment to print new data immediately!
}
}
}
if (newdata) {
Serial.println("Acquired Data");
Serial.println("-------------");
float gpslat;
float gpslong;
gps.f_get_position(&gpslat, &gpslong);
latmax = gpslat + margem;
latmin = gpslat - margem;
longmax = gpslong + margem;
longmin = gpslong - margem;
Serial.println("-------------");
Serial.println();
}
for(int i = 0; i < tracksize; i++){
delay(10);
while ((tracklat[i] <= latmax) && (tracklat[i] >= latmin) && (tracklong[i] <= longmax) && (tracklong[i] >= longmin)) {
Serial.println("True");
digitalWrite(led, HIGH);
delay(10);
break;
}
}
}
====================================
The code above, as I mentioned, is perfect for what I need!
Here's my big problem, how can I put the "floats" coordinates inside an SDcard so I can have more coordinates to add?
Example (explaining roughly):
float tracklat [] = {latitude.txt};
float tracklong [] = {longitude.txt};
Thanks in advance for any help !!!