test

Dependencies:   mbed MMA8452Q

Fork of HelloWorld by Simon Ford

Revision:
16:0b58c14b639d
Parent:
15:b4b2e73faefb
Child:
17:c463c5a434ec
diff -r b4b2e73faefb -r 0b58c14b639d main.cpp
--- a/main.cpp	Thu Aug 31 15:47:06 2017 +0000
+++ b/main.cpp	Thu Aug 31 16:52:41 2017 +0000
@@ -13,14 +13,15 @@
  
      MMA8452Q acc(p9,p10,0x1d);     // acceleration object
  
-     while (true) {       
+     //while (true) {       
         // x = acc.getAccX() ;
         // y = acc.getAccY() ;
         // z = acc.getAccZ() ;
         // printf("X[%.2f] Y[%.2f] Z[%.2f]\n",x, y, z) ;
          wait(0.1);
 
-        float z = 0.707;
+       // float angle = ((2*x*x+2*y*y)/(x*x+y*y+z*z))+1;
+        
         float resultat = (3.14/2.0) -( z + (z *z * z)/6.0 + (3*z*z*z*z*z)/40.0);
         pc.printf("valeur rad = %f", resultat);
         float degree = resultat * 18000.0/314.0;
@@ -29,13 +30,14 @@
         int degreInt = (int)degree;
         pc.printf("valeur deg = %d", degreInt);
          
-         
+        int rep;
          // extracting digits
-        char digits[4];
+        int digits[4] = {0,0,0,0};
         int i = 0;
         while(degreInt > 0) {
-        digits[i]= degreInt % 10;    //to get the right most digit
-        pc.printf("digit %c = %c", i, digits[i]);
+        rep = degreInt % 10; //to get the right most digit
+        digits[i]=rep;
+        pc.printf("digit %d = %d, degree int: %d", i, digits[i], degreInt);
         degreInt /= 10;              //reduce the number by one digit
         ++i;
         }
@@ -43,14 +45,25 @@
          
          
          
-         /*
+         
          cs = 0;
-         accel.write(x);
+         accel.write(digits[3]);
+         cs = 1;
+         wait(2);
+         cs = 0;
+         accel.write(digits[2]);
          cs = 1;
-         wait(0.2);
-         cs = 0;*/
+         wait(2);
+         cs = 0;
+         accel.write(digits[1]);
+         cs = 1;
+         wait(2);
+         cs = 0;
+         accel.write(digits[0]);
+         cs = 1;
+         wait(2);
          wait(1); 
-        }
+        
 }