Example to sweep a servo according to MEMS sensors position

Dependencies:   Servo X_NUCLEO_IKS01A1 mbed

Fork of HelloWorld_IKS01A1 by ST

Revision:
9:10f36a418bc0
Parent:
4:b1526d074d83
--- a/main.cpp	Thu Dec 17 11:03:49 2015 +0000
+++ b/main.cpp	Thu Oct 06 10:11:06 2016 +0000
@@ -40,6 +40,10 @@
 #include "mbed.h"
 #include "x_nucleo_iks01a1.h"
 
+#include "Servo.h"
+
+Servo myservo(D3);
+
 /* Instantiate the expansion board */
 static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15);
 
@@ -126,9 +130,11 @@
     accelerometer->Get_X_Axes(axes);
     printf("LSM6DS0 [acc/mg]:      %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
 
+    myservo = (1000.0-axes[2])/1000.0;
+
     gyroscope->Get_G_Axes(axes);
     printf("LSM6DS0 [gyro/mdps]:   %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]);
 
-    wait(1.5);
+    wait(0.2);
   }
 }