noop din / Mbed OS Accelerometer_example

Dependencies:   MMA8451Q

Fork of Accelerometer_example by William Marsh

Files at this revision

API Documentation at this revision

Comitter:
WilliamMarshQMUL
Date:
Wed Feb 08 19:25:08 2017 +0000
Child:
1:31f0f53b08bd
Commit message:
First version for lab 4

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-rtos.lib 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/MMA8451Q.lib	Wed Feb 08 19:25:08 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 Feb 08 19:25:08 2017 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "MMA8451Q.h"
+
+  PinName const SDA = PTE25;
+  PinName const SCL = PTE24;
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+int main(void)
+{
+    MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
+    PwmOut rled(LED1);
+    PwmOut gled(LED2);
+    PwmOut bled(LED3);
+    Serial pc(USBTX, USBRX); // tx, rx
+
+
+    pc.printf("MMA8451 ID: %d\n", acc.getWhoAmI());
+
+    while (true) {
+        float x, y, z;
+        x = acc.getAccX();
+        y = acc.getAccY();
+        z = acc.getAccZ();
+        rled = 1.0f - abs(x);
+        gled = 1.0f - abs(y);
+        bled = 1.0f - abs(z);
+        Thread::wait(300);
+        pc.printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Feb 08 19:25:08 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 08 19:25:08 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/99b5ccf27215
\ No newline at end of file