j

Dependencies:   mbed MMA8451Q

Files at this revision

API Documentation at this revision

Comitter:
intersect20
Date:
Wed Feb 24 15:28:47 2021 +0000
Commit message:
accelerometro;

Changed in this revision

MMA8451Q.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
diff -r 000000000000 -r 5136e0cabcba MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Wed Feb 24 15:28:47 2021 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
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);
+    }
+}
diff -r 000000000000 -r 5136e0cabcba mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 24 15:28:47 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file