when the user shakes the board, then on board led toggles to a different color

Dependencies:   MMA8451Q mbed

Revision:
0:b3a1604a669c
diff -r 000000000000 -r b3a1604a669c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 10 09:26:09 2015 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+Serial pc(USBTX,USBRX);
+DigitalOut red(LED1);
+DigitalOut green(LED2);
+DigitalOut blue(LED3);
+int i=0;
+int xaxis, yaxis, zaxis;
+int main(void)
+{
+    while(1)
+    {
+        xaxis=(acc.getAccX()+1)*100;
+        yaxis=(acc.getAccY()+1)*100;
+        zaxis=(acc.getAccZ()+1)*100;
+        pc.printf("$%d %d %d;",xaxis,yaxis,zaxis);
+        
+        if ( xaxis>=250 || yaxis >= 250 || zaxis >= 250)
+        i++;
+        
+        if(i==1)
+        {red=0;
+         green=1;
+         blue=1;
+         }
+         if(i==2)
+        {red=1;
+         green=0;
+         blue=1;
+         }
+         if(i==3)
+        {red=1;
+         green=1;
+         blue=0;
+         i=0;
+         }
+        wait(0.1);
+        }
+        }
+        
+        
\ No newline at end of file