megan gimple / Mbed 2 deprecated OCE360_Final_Project

Dependencies:   mbed MMA8452Q MS5837 SDFileSystem SCI_SENSOR

Revision:
25:69027120c44f
Parent:
24:35e052072b64
Child:
26:379bc50f5f23
diff -r 35e052072b64 -r 69027120c44f main.cpp
--- a/main.cpp	Tue Dec 07 15:23:51 2021 +0000
+++ b/main.cpp	Wed Dec 08 19:06:37 2021 +0000
@@ -1,7 +1,7 @@
 //OCE 360 Final Project
 //Annaliese Nardi, Eliza Taylor, Mackenzie Fraser, Megan Gimple
 //Updated Code by Stephen Licht
-//Description:
+//Description: This code controls the movement of a UAV. Collects pressure, temperaure, light, and acceleration data and writes that to a file on an onboard SD card.
 
 #include "mbed.h"
 #include "MMA8452Q.h"  //accelerometer library
@@ -91,8 +91,8 @@
     wait(1);
 
     //Part One
-    int count=1;
-    while(count<=3) {
+    int count=0;
+    while(count<3) {
         count=count+1;
         float pw= percent;
         float on_time =tim;
@@ -164,7 +164,7 @@
         } else {
             BLE.printf("##file open good \n"); //open file and tell if open
             fprintf(fp, "Hello\r\n");
-            //fclose(fp);
+            fclose(fp);
         }
 
         BLE.printf("### The main program will start in 5 seconds\r\n");
@@ -187,9 +187,10 @@
         //Sample code indicates how to read accelerometer data:    
         BLE.printf("Acceleration: %f %f %f\r\n",accelData[0],accelData[1],accelData[2]);   
         //end of code from Licht
-
+        
+        fopen(fp);
         fprintf(fp, "$DATA, %f, %f, %f, %f, %f, %f, %f, %f, %f\r\n", t.read(),p_sensor.MS5837_Pressure(),p_sensor.depth(),accelData[0],accelData[1],accelData[2],temp.temp(),light.light(),percent);
-
+        fclose(fp);
     }
 
 ///-----------acceleromter related functions---------------------///