j

Dependencies:   mbed MMA8451Q

Revision:
0:5136e0cabcba
diff -r 000000000000 -r 5136e0cabcba main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 24 15:28:47 2021 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+Serial pc (USBTX,USBRX);
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+
+int main(void)
+{
+    pc.baud(115200);
+    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+
+    pc.printf("MMA8451 ID: %d\n\r", acc.getWhoAmI());
+
+    while (true) {
+        float x, y, z;
+        x = abs(acc.getAccX());
+        y = abs(acc.getAccY());
+        z = abs(acc.getAccZ());
+        wait(0.1f);
+        pc.printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n\r", x, y, z);
+        wait(1);
+    }
+}