Tilt steering control

Dependencies:   MMA8451Q mbed

Files at this revision

API Documentation at this revision

Comitter:
pemb4660
Date:
Tue Jun 07 15:31:48 2016 +0000
Commit message:
steering control

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 8e22f474256a MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Tue Jun 07 15:31:48 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
diff -r 000000000000 -r 8e22f474256a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 07 15:31:48 2016 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+int main()
+{
+    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+    PwmOut rled(LED_RED);
+    PwmOut gled(LED_GREEN);
+    bool right;
+
+    while (1) {
+
+        if(acc.getAccX() <= 0.1 && acc.getAccX() >= -0.1) {
+            if (right == true) {
+                rled = 0;
+            } else
+                gled = 0;
+        }
+
+        if (acc.getAccX() > 0.1) {
+            rled = 0;
+            gled = 1;
+            right = true;
+        }
+
+        if (acc.getAccX() < -0.1) {
+            rled = 1;
+            gled = 0;
+            right = false;
+        }
+        wait(0.1);
+    }
+
+}
diff -r 000000000000 -r 8e22f474256a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 07 15:31:48 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file