2nd version

Dependencies:   GPS mbed

Committer:
gegjackson
Date:
Tue Mar 01 15:08:54 2016 +0000
Revision:
0:0cfced8c9bac
b

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gegjackson 0:0cfced8c9bac 1 #include "mbed.h"
gegjackson 0:0cfced8c9bac 2 #include "GPS.h"
gegjackson 0:0cfced8c9bac 3 /*THIS FILE IS MADE TO RUN ON THE MBED. IT WILL TAKE A GPS VALUE AND WRITE IT
gegjackson 0:0cfced8c9bac 4 TO A TEXT FILE*/
gegjackson 0:0cfced8c9bac 5
gegjackson 0:0cfced8c9bac 6 Serial pc(USBTX, USBRX);
gegjackson 0:0cfced8c9bac 7 GPS gps(p9, p10);
gegjackson 0:0cfced8c9bac 8 LocalFileSystem local("local"); // Create the local filesystem called "local"
gegjackson 0:0cfced8c9bac 9 DigitalOut myled(LED2); //different led from the accelerometer value so when we combine the code there will be no overlap
gegjackson 0:0cfced8c9bac 10
gegjackson 0:0cfced8c9bac 11 int main() {
gegjackson 0:0cfced8c9bac 12 //if(gps.sample())
gegjackson 0:0cfced8c9bac 13 // {
gegjackson 0:0cfced8c9bac 14 FILE *fpgps = fopen("/local/gpsvalue.txt", "w"); // Open "gpsvalue.txt"
gegjackson 0:0cfced8c9bac 15 fprintf(fpgps,"I'm at longitude: %f latitude: %f \n", gps.longitude, gps.latitude);
gegjackson 0:0cfced8c9bac 16 //this simply prints the gps values in a text file. we only need to do this once as we are assuming the mbed will stay at the same long and lat while taking data.
gegjackson 0:0cfced8c9bac 17 fclose(fpgps); //save and close the file
gegjackson 0:0cfced8c9bac 18 myled = 1;//two short flashes for a succesfull gps reading
gegjackson 0:0cfced8c9bac 19 wait(0.2);
gegjackson 0:0cfced8c9bac 20 myled = 0;
gegjackson 0:0cfced8c9bac 21 wait(0.2);
gegjackson 0:0cfced8c9bac 22 myled = 1;
gegjackson 0:0cfced8c9bac 23 wait(0.2);
gegjackson 0:0cfced8c9bac 24 myled = 0;
gegjackson 0:0cfced8c9bac 25 wait(0.2);
gegjackson 0:0cfced8c9bac 26
gegjackson 0:0cfced8c9bac 27 //} else {
gegjackson 0:0cfced8c9bac 28 // myled = 1;//one long flash for a failure to lock on to the gps
gegjackson 0:0cfced8c9bac 29 // wait(0.5);
gegjackson 0:0cfced8c9bac 30 // myled = 0;
gegjackson 0:0cfced8c9bac 31 // wait(0.5);
gegjackson 0:0cfced8c9bac 32
gegjackson 0:0cfced8c9bac 33 }