Currently, I want to create car automation using fuzzy logic. This car will follow the path it has been traveled before using GPS latitude and longitude that saved into an sd card. so when the remote activates the feature the GPS will stop storing data in SD CARD, and the data that has been saved before should be sent back on the Arduino as a waypoint float.
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
float waypoint;
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
// re-open the file for reading:
myFile = SD.open("GPS_data.txt");
if (myFile) {
Serial.println("GPS_data.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
waypoint = Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// nothing happens after setup
}
MODERATOR EDIT
Fixed the code tags for you