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:
- 8:f1679795e9ac
- Parent:
- 7:c08305966384
- Child:
- 9:dbb7c4e63d45
diff -r c08305966384 -r f1679795e9ac main.cpp --- a/main.cpp Tue Mar 14 16:00:12 2017 +0000 +++ b/main.cpp Tue Mar 14 16:35:12 2017 +0000 @@ -34,20 +34,21 @@ FILE *GPS = fopen("/USB/GPS.txt", "w"); // Opens text file for GPS FILE *Comp = fopen("/USB/Compass.txt", "w"); // Opens text file for Compass - float Offset; int i; + Accel = fopen("/USB/Accelerometer.txt", "a"); + + while(i < LIM) { //Accelerometer - Accel = fopen("/USB/Accelerometer.txt", "a"); + ax=MMA.x(); ay=MMA.y(); az=MMA.z(); fprintf(Accel,"%f, %f, %f,\r\n",ax,ay,az); lcd.locate(1,21); lcd.printf("Accel: %.2f, %.2f, %.2f", ax, ay, az); - wait (0.5); /* //GPS GPS = fopen("/USB/GPS.txt", "a"); @@ -66,12 +67,16 @@ */ // Compass //Offset = compass.readBearing(); // Initial definitions - // GenBearing = (compass.readBearing()/10 - Offset/10); + + lcd.locate(1,11); + lcd.printf("Bearing: %.2f\n", compass.readBearing() / 10.0); + /* Comp = fopen("/USB/Compass.txt", "a"); fprintf(Comp, "%f\r\n", compass.readBearing()); lcd.locate(1,11); - lcd.printf("Offset: %f, CMP: %f", Offset, compass.readBearing()); - + // lcd.printf("Offset: %f, CMP: %f", Offset, compass.readBearing()); + lcd.printf("Bearing:%f\n", compass.readBearing() / 10.0); + */ /* GenBearing = compass.readBearing()/10; Comp = fopen("/USB/Compass.txt", "a"); @@ -83,9 +88,11 @@ lcd.locate(1,11); lcd.printf("Offset: %.2f, CMP: %.2f", Offset/10.0, GenBearing); */ - fclose(Accel); + wait (0.5); + + i++; + } + fclose(Accel); //fclose(GPS); fclose(Comp); - i++; - } } \ No newline at end of file