Lightsaber project

Dependencies:   MMA8451Q TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
alexwynn41
Date:
Fri Apr 01 18:27:00 2016 +0000
Commit message:
Initial Commit

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
TSI.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 7e186c670eda MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Fri Apr 01 18:27:00 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
diff -r 000000000000 -r 7e186c670eda TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Fri Apr 01 18:27:00 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
diff -r 000000000000 -r 7e186c670eda main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 01 18:27:00 2016 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+#include "TSISensor.h"
+
+#if   defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
+  PinName const SDA = PTE25;
+  PinName const SCL = PTE24;
+#elif defined (TARGET_KL05Z)
+  PinName const SDA = PTB4;
+  PinName const SCL = PTB3;
+#elif defined (TARGET_K20D50M)
+  PinName const SDA = PTB1;
+  PinName const SCL = PTB0;
+#else
+  #error TARGET NOT DEFINED
+#endif
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+Timer t;
+TSISensor tsi;
+
+int main(void)
+{
+    MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
+    PwmOut rled(LED1);
+    PwmOut gled(LED2);
+    PwmOut bled(LED3);
+    float led;
+
+    while (true) {
+        float x0, y0, z0, x1, y1, z1;
+        x0 = abs(acc.getAccX());
+        y0 = abs(acc.getAccY());
+        z0 = abs(acc.getAccZ());
+        wait(0.1);
+        x1 = abs(acc.getAccX());
+        y1 = abs(acc.getAccY());
+        z1 = abs(acc.getAccZ());
+        led = 1.0 - tsi.readPercentage();
+        if(x1 - x0 > 0.6 || y1 - y0 > 0.6 || z1 - z0 > 0.6 ){
+            bled = 1.0f;
+            rled = 1.0f;
+            wait(0.1);
+        }
+        
+        bled = led;
+        rled = led;
+        gled = led;    
+        //rled = 1.0f - x0;
+        //gled = 1.0f - y0;
+        //bled = 1.0f - z0;
+        wait(0.1f);
+        //printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z);
+    }
+}
diff -r 000000000000 -r 7e186c670eda mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 01 18:27:00 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file