NONE

Dependencies:   MMA8451Q USBDevice mbed

Fork of USBMouse_HelloWorld by Samuel Mokrani

Revision:
5:15f41f12f4eb
Parent:
3:b8caa902d79e
--- a/main.cpp	Fri Mar 01 13:26:13 2013 +0000
+++ b/main.cpp	Fri Jul 07 01:07:38 2017 +0000
@@ -1,20 +1,36 @@
 #include "mbed.h"
 #include "USBMouse.h"
+#include "MMA8451Q.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)
 
 USBMouse mouse;
 
 int main() {
-    int16_t x = 0;
-    int16_t y = 0;
-    int32_t radius = 10;
-    int32_t angle = 0;
-
+    int x, y,z;
+    
+    
+    MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
     while (1) {
-        x = cos((double)angle*3.14/180.0)*radius;
-        y = sin((double)angle*3.14/180.0)*radius;
+        
+        x =1.0f- abs(10*acc.getAccX());
+        y = 1.0f- abs(10*acc.getAccY());
+        z = 1.0f-abs(10*acc.getAccZ());
         
         mouse.move(x, y);
-        angle += 3;
         wait(0.001);
     }
 }
\ No newline at end of file