accelorometer and touch pad

Dependencies:   MMA8451Q TSIServo mbed

Fork of FRDM_MMA8451Q by mbed official

Files at this revision

API Documentation at this revision

Comitter:
cindyC12
Date:
Sun Sep 23 04:41:13 2018 +0000
Parent:
7:70775be9f474
Child:
9:1f50587ada14
Commit message:
it work. sortof

Changed in this revision

TSIServo.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSIServo.lib	Sun Sep 23 04:41:13 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/RafaB/code/TSIServo/#53d8d4e25c00
--- a/main.cpp	Tue Feb 19 23:46:45 2013 +0000
+++ b/main.cpp	Sun Sep 23 04:41:13 2018 +0000
@@ -1,18 +1,25 @@
 #include "mbed.h"
 #include "MMA8451Q.h"
+#include "TSISensor.h"
 
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
 
 int main(void) {
     MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
-    PwmOut rled(LED_RED);
-    PwmOut gled(LED_GREEN);
-    PwmOut bled(LED_BLUE);
+    PwmOut r(LED_RED);
+    PwmOut g(LED_GREEN);
+    PwmOut b(LED_BLUE);
+     TSISensor tsi;
+     float readPercentage();
+     
 
     while (true) {
-        rled = 1.0 - abs(acc.getAccX());
-        gled = 1.0 - abs(acc.getAccY());
-        bled = 1.0 - abs(acc.getAccZ());
+        r = abs(acc.getAccX()* tsi.readPercentage());
+        r = 1.0 - (r*tsi.readPercentage());
+        g = abs(acc.getAccY()* tsi.readPercentage());
+        g = 1.0 - (g*tsi.readPercentage());
+        b = abs(acc.getAccZ()* tsi.readPercentage());
+        b = 1.0 - (b*tsi.readPercentage());
         wait(0.1);
     }
 }