part3

Dependencies:   MMA7660 mbed

Files at this revision

API Documentation at this revision

Comitter:
jaredwil
Date:
Tue Mar 03 19:24:53 2015 +0000
Commit message:
part3;

Changed in this revision

MMA7660.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/MMA7660.lib	Tue Mar 03 19:24:53 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 03 19:24:53 2015 +0000
@@ -0,0 +1,69 @@
+//Uses the measured z-acceleration to drive leds 2 and 3 of the mbed
+ 
+#include "mbed.h"
+#include "MMA7660.h"
+ 
+MMA7660 MMA(p28, p27);
+BusOut leds(LED1,LED2,LED3,LED4);
+
+//used for debugging
+Serial pc(USBTX, USBRX);
+ 
+int main() {  
+    if (MMA.testConnection())
+        leds = 0x1;
+        wait(1);
+        leds = 0x0;
+        float x = 0, y = 0, z = 0;
+    while(1) {
+        leds = 0x0;
+        x = MMA.x();
+        y = MMA.y();
+        z = MMA.z();
+        
+//NOTE: All directions based on looking at device with MBED cord towards
+//the user       
+        if(x > 0.5){  //Forward
+            leds = 0x6;
+            wait(1);
+        }
+        if(x < -0.5){  //Backwards
+            leds = 0x9;
+            wait(1);
+        }
+         if(y > 0.5){  //LEFT
+            leds = 0xE;
+            wait(1);
+        }
+        if(y < -0.5){  //RIGHT
+            leds = 0x7;
+            wait(1);
+        }
+        if((z) > 1.2){  //UP
+            leds = 0xF;
+            wait(1);
+        }
+        if((z) < 0.5){  //DOWN
+            leds = 0xA;
+            wait(0.2);
+            leds = 0x5;
+            wait(0.2);
+            leds = 0xA;
+            wait(0.2);
+            leds = 0x5;
+            wait(0.2);
+            leds = 0xA;
+            wait(0.2);
+            leds = 0x5;
+            wait(0.2);
+        }
+        
+        
+        
+        
+        //for debug
+        //pc.printf("x: %f  y: %f z: %f \r",MMA.x(),MMA.y(),MMA.z());
+      
+    }
+ 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 03 19:24:53 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file