Mrunal Mirani / Mbed 2 deprecated Exp4

Dependencies:   MMA8451Q mbed

Files at this revision

API Documentation at this revision

Comitter:
mrunalmirani
Date:
Wed Jan 18 02:58:53 2017 +0000
Commit message:
fyhv

Changed in this revision

Exp4.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/Exp4.lib	Wed Jan 18 02:58:53 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 18 02:58:53 2017 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+
+
+  PinName const SDA = PTE25;
+  PinName const SCL = PTE24;
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+Ticker acctick;
+DigitalOut fallled(LED2);
+void acctick_isr(void);
+void acctick_isr(void)
+{
+    float x, y, z,a;
+        x = acc.getAccX();
+        y = acc.getAccY();
+        z = acc.getAccZ();
+        a=sqrt(pow(x,2)+pow(y,2)+pow(z,2));
+        wait(0.1f);
+        printf("X: %1.2f, Y: %1.2f, Z: %1.2f, a: %1.2f \n", x, y, z,a);
+}
+int main(void)
+{
+    MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
+    fallled=1;
+    acctick.attach(&acctick_isr,0.01);
+    printf("MMA8451 ID: %d\n", acc.getWhoAmI());
+
+    while (true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jan 18 02:58:53 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5
\ No newline at end of file