3256

Dependencies:   MMA8451Q mbed

Revision:
0:3014b1c9fb29
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 04 06:40:27 2017 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+
+MMA8451Q acc(PTE25,PTE24,0X1d<<1);
+Serial pc(USBTX,USBRX);
+
+BusOut myled(PTB18,PTB19,PTD1);
+float x,y;
+
+ int main()
+{ 
+    while(1)
+    { 
+    y = acc.getAccY();
+    x = acc.getAccX();
+    if ((x>-0.2 && x<0.2) && (y>-0.2 && y<0.2)){
+    pc.printf("NO Tilt in X direction");
+    myled = 0x06;
+    }
+    else if ((x>-0.6 && x<-0.2 | x> 0.2 && x<0.6) || (y>-0.6 && y<-0.2 | y> 0.2 && y<0.6) )
+    {
+        pc.printf("High Tilt in X Direction");
+        myled =0x05 ;
+    }
+
+    else if((x<-0.6 | x>0.6) || (y<-0.6 | y>0.6))
+    { pc.printf("extremely Tilted");
+      myled = 0x03;
+    }                           
+}
+    
+}