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:
- 9:dbb7c4e63d45
- Parent:
- 8:f1679795e9ac
- Child:
- 10:d2dd3b355de5
diff -r f1679795e9ac -r dbb7c4e63d45 main.cpp --- a/main.cpp Tue Mar 14 16:35:12 2017 +0000 +++ b/main.cpp Thu Mar 16 15:19:33 2017 +0000 @@ -22,11 +22,11 @@ int main() { - /* + DIR *d; struct dirent *p; // For printing externally (USB Stick) d = opendir("/" FSNAME); - */ + if (MMA.testConnection()) connectionLed = 1; // Checking MMA connected correctly @@ -36,13 +36,11 @@ 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(); @@ -67,9 +65,10 @@ */ // Compass //Offset = compass.readBearing(); // Initial definitions - + Comp = fopen("/USB/Compass.txt", "a"); + fprintf(Comp, "%f\r\n", compass.readBearing()/10); lcd.locate(1,11); - lcd.printf("Bearing: %.2f\n", compass.readBearing() / 10.0); + lcd.printf("Bearing: %.2f\n", compass.readBearing()/10.0); /* Comp = fopen("/USB/Compass.txt", "a"); fprintf(Comp, "%f\r\n", compass.readBearing()); @@ -91,8 +90,9 @@ wait (0.5); i++; - } - fclose(Accel); + fclose(Accel); //fclose(GPS); fclose(Comp); + } + } \ No newline at end of file