Contador de pasos

Dependencies:   MMA8451Q mbed

Revision:
10:5b9057acf106
Parent:
9:ff57931068f4
Child:
12:a73fdd04a291
--- a/main.cpp	Fri Feb 12 13:57:04 2016 +0000
+++ b/main.cpp	Sat Feb 13 01:40:47 2016 +0000
@@ -7,7 +7,7 @@
 PwmOut gled(LED_GREEN);
 PwmOut bled(LED_BLUE);
 int16_t data [3];
-int cont,z;
+int cont1,cont,z;
 
 int main() {
    pc.baud(9600);
@@ -19,12 +19,20 @@
         
        // serial1.printf("%d\n",data[0]);  
       //  serial1.printf("%d\n",data[1]); 
-        pc.printf("%d\n",data[2]);
+       pc.printf("%d\n",data[2]);
         
-      //   rled = 1.0 - abs(data[0]/17000.0);
+       // rled1.0 - abs(data[0]/10.0);
       //   gled = 1.0 - abs(data[1]/17000.0);
-         z=bled = 1.0 - abs(data[2]/17000.0);
+           z= 1.0 - abs(data[2]/10.0);
          wait(0.4);
 
-
-   }}
+   if(-4000>data[2]){
+   cont1++;
+   pc.printf("%d\n",cont1);
+   if(-4000<data[2])
+    pc.printf("%d\n",0);
+    //}else{
+      // cont=0;
+       
+    }}}
+