Dependencies:   mbed PinDetect

Revision:
1:aaa03bac6dd6
Parent:
0:eff94d72c9f4
Child:
2:59677142d3dd
--- a/main.cpp	Thu Dec 06 02:48:05 2018 +0000
+++ b/main.cpp	Mon Dec 10 22:27:35 2018 +0000
@@ -21,7 +21,7 @@
 int main() {
 
    pb1.mode(PullUp);
-   
+   int timer = 0;
    double x = 0, y = 0, z = 0;
    MMA8452 acc(p28, p27, 40000);  //instantiate an acc object 
    
@@ -33,36 +33,20 @@
    
    while(1) {
 
-//      if(!acc.isXYZReady()) 
-//      {
-//         wait(0.01);
-//      }
-//      else
-//      { 
       acc.readXYZGravity(&x,&y,&z); //notice this is passed by reference use pointers
-      
-      if(y < 0)
-      _base.write(90+(y*-.90));
-      else
-      _base.write(90-(y*-.90));
-      
-      if(x < 0)
-      _shoulder.write(90+(x*-.90));
-      else
-      _shoulder.write(90-(x*-.90));
-      
+
+      _base.write((y+1)/2);
+      _shoulder.write((x+1)/2);
+
       if(!pb1){
         myLed=1;
         swing();
         myLed=0;
     }
-                 
-                 
+                          
       // You can uncomment this line to see the values coming off the MMA8452           
-      printf("\n(%.2f,%.2f,%.2f)  \n", x,y,z);
+      //printf("\n(%.2f,%.2f,%.2f)", x,y,z);
       
-      } //end else
-      
-   } //end infinite while loop
-//} // end main
-
+      timer++;      
+      } //infinite while loop 
+   } //end main
\ No newline at end of file