Data collection project

Dependencies:   mbed MMA8452Q SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
ccschneider
Date:
Sun Dec 23 17:13:49 2018 +0000
Commit message:
Data collection project;

Changed in this revision

MMA8452Q.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8452Q.lib	Sun Dec 23 17:13:49 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/ccschneider/code/MMA8452Q/#3f5c2ab23593
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Sun Dec 23 17:13:49 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/neilt6/code/SDFileSystem/#dbbce3e35e09
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 23 17:13:49 2018 +0000
@@ -0,0 +1,67 @@
+// Cecilia Schneider
+// OCE 360 Final Project 
+
+#include "mbed.h"
+#include "MMA8452Q.h"
+#include "SDFileSystem.h"
+
+// AnalogIn ain(p15); // temp sensor on p15
+DigitalIn switchin(p11); // switch on p11
+
+// Accelerometer
+MMA8452Q accel(p28, p27, 0x1D); // Accelerometer - SDA, SCL, and I2C address
+
+// Serial terminal 
+Serial pc(USBTX, USBRX);
+
+// SD card reader
+SDFileSystem sd(p5, p6, p7, p8, "sd"); 
+
+int main() {
+    // initialize accelerometer
+    accel.init(); 
+    float x;
+    float y;
+    float z;
+
+    // define and open file 
+    FILE *file;
+    file = fopen("/sd/acceldata.txt", "w"); 
+       
+    while(1){
+        if (switchin == 1){ // store data from accelerometer in x, y , z
+            x = accel.readX();
+            y = accel.readY();
+            z = accel.readZ();
+            fprintf(file, "%3.2f %3.2f %3.2f \n\r", x, y, z); // write accelerometer data to file
+        }
+        else ()
+            fclose(file); // close file here 
+            file = fopen("/sd/acceldata.txt","r"); // reopen for reading 
+            pc.printf("%3.2f %3.2f %3.2f \n\r", x, y, z); // print data to serial terminal 
+            pc.printf("TEST");
+            break; // only do this once?
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 23 17:13:49 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file