Program to read data from sensors, write them to a file which can then be interpreted by software to help show the path of a bicycle as it travels around a field
Dependencies: C12832_lcd FatFileSystemCpp MMA7660 CMPS03 GPS
Fork of MSCUsbHost by
Program to link a compass and a GPS to an MBED to produce a CSV file which can be used to track a bicycle around a field
Results can be found here
Diff: main.cpp
- Revision:
- 10:d2dd3b355de5
- Parent:
- 9:dbb7c4e63d45
- Child:
- 11:c85911a4c956
--- a/main.cpp Thu Mar 16 15:19:33 2017 +0000 +++ b/main.cpp Thu Mar 16 15:52:05 2017 +0000 @@ -22,17 +22,17 @@ int main() { - + /* DIR *d; struct dirent *p; // For printing externally (USB Stick) d = opendir("/" FSNAME); - + */ if (MMA.testConnection()) connectionLed = 1; // Checking MMA connected correctly - FILE *Accel = fopen("/USB/Accelerometer.txt", "w"); // Opens text file for Accelerometer - FILE *GPS = fopen("/USB/GPS.txt", "w"); // Opens text file for GPS - FILE *Comp = fopen("/USB/Compass.txt", "w"); // Opens text file for Compass + FILE *Accel = fopen("/USB/Accelerometer.csv", "w"); // Opens text file for Accelerometer + FILE *GPS = fopen("/USB/GPS.csv", "w"); // Opens text file for GPS + FILE *Comp = fopen("/USB/Compass.csv", "w"); // Opens text file for Compass int i; @@ -40,7 +40,7 @@ while(i < LIM) { //Accelerometer - Accel = fopen("/USB/Accelerometer.txt", "a"); + Accel = fopen("/USB/Accelerometer.csv", "a"); ax=MMA.x(); ay=MMA.y(); az=MMA.z(); @@ -49,7 +49,7 @@ lcd.printf("Accel: %.2f, %.2f, %.2f", ax, ay, az); /* //GPS - GPS = fopen("/USB/GPS.txt", "a"); + GPS = fopen("/USB/GPS.csv", "a"); if (gps.sample()) { fprintf(GPS, "\n%f, %f\r\n", gps.latitude, gps.longitude); @@ -65,10 +65,10 @@ */ // Compass //Offset = compass.readBearing(); // Initial definitions - Comp = fopen("/USB/Compass.txt", "a"); - fprintf(Comp, "%f\r\n", compass.readBearing()/10); + Comp = fopen("/USB/Compass.csv", "a"); lcd.locate(1,11); lcd.printf("Bearing: %.2f\n", compass.readBearing()/10.0); + fprintf(Comp, "%.2f\r\n", compass.readBearing()/10.0); /* Comp = fopen("/USB/Compass.txt", "a"); fprintf(Comp, "%f\r\n", compass.readBearing()); @@ -85,7 +85,7 @@ } fprintf(Comp, "%f\r\n", GenBearing); lcd.locate(1,11); - lcd.printf("Offset: %.2f, CMP: %.2f", Offset/10.0, GenBearing); + lcd.printf("CMP: %.2f", Offset/10.0, GenBearing); */ wait (0.5);