MMA interface with the on board accelerometer ,prints the X,YandZ vaues every second

Dependencies:   mbed MMA7660

Files at this revision

API Documentation at this revision

Comitter:
t00203959
Date:
Wed May 22 10:48:24 2019 +0000
Commit message:
Digital sensors and Equations in C

Changed in this revision

MMA7660.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/MMA7660.lib	Wed May 22 10:48:24 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Sissors/code/MMA7660/#36a163511e34
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 22 10:48:24 2019 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "MMA7660.h"
+
+
+Serial pc(USBTX, USBRX); //tx rx
+MMA7660 MMA(p28, p27);
+
+float calculateAngle (float x, float y, float z)
+{
+    float angle =0;
+
+    angle = (atan (x/ sqrt((y*y)+(z*z)))*180/3.17);
+
+    return angle;
+
+}
+
+int main ()
+{
+// if MMA.test connection() ) //
+
+    while (1) {
+        printf("x %f, y %f, z %f ang %f\n\r", MMA.x(), MMA.y(), MMA.z(), calculateAngle(MMA.x(), MMA.y(), MMA.z()));
+        wait (1);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 22 10:48:24 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file