Shape shifter - controller

Dependencies:   DebounceIn MMA8451Q USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
Maskax
Date:
Wed Sep 16 23:40:54 2015 +0000
Commit message:
HW3_ShapeShifter_ED

Changed in this revision

DebounceIn.lib Show annotated file Show diff for this revision Revisions of this file
MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.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 a80df48a0372 DebounceIn.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DebounceIn.lib	Wed Sep 16 23:40:54 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/DebounceIn/#31ae5cfb44a4
diff -r 000000000000 -r a80df48a0372 MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Wed Sep 16 23:40:54 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
diff -r 000000000000 -r a80df48a0372 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Wed Sep 16 23:40:54 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mjr/code/USBDevice/#a8eb758f4074
diff -r 000000000000 -r a80df48a0372 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 16 23:40:54 2015 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+//#include "PinDetect.h"
+#include "MMA8451Q.h"
+#include "USBKeyboard.h"
+
+USBKeyboard key;
+
+// define I2C Pins and address for KL25Z. Taken from default sample code.
+PinName const SDA = PTE25;
+PinName const SCL = PTE24;
+//PinDetect P0(D2);
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+//serial connection to PC via USB
+//Serial pc(USBTX, USBRX);
+
+int main(void)
+{
+    //configure on-board I2C accelerometer on KL25Z
+    MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); 
+    //map read acceleration to PWM output on red status LED
+
+    while (true) {
+        float x, y, z;
+            x = acc.getAccX();
+            y = acc.getAccY();
+            wait(0.05f);
+            
+            while (y<-0.2){            
+                key.keyCode(LEFT_ARROW);
+                x = acc.getAccX();
+                y = acc.getAccY();
+                //key.printf("left arrow\n");
+                if (x<-1.9)
+                    {
+                    //   key.printf("Salto\n");
+                    key.keyCode(UP_ARROW);
+                    wait(0.3f);                  
+                    }
+                }
+            while (y>0.2){
+                key.keyCode(RIGHT_ARROW);
+                x = acc.getAccX();
+                y = acc.getAccY();
+                //key.printf("right arrow\n");
+                if (x<-1.9)
+                    {
+                    //   key.printf("Salto\n");
+                    key.keyCode(UP_ARROW);
+                    wait(0.3f);
+                    }
+                }      
+            if (x<-1.9)
+                {
+             //   key.printf("Salto\n");
+                key.keyCode(UP_ARROW);
+                x = acc.getAccX();
+                wait(0.3f);
+               }
+            //wait(0.5);*/
+        }
+    }
diff -r 000000000000 -r a80df48a0372 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 16 23:40:54 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file