Example to sweep a servo according to MEMS sensors position

Dependencies:   Servo X_NUCLEO_IKS01A1 mbed

Fork of HelloWorld_IKS01A1 by ST

Files at this revision

API Documentation at this revision

Comitter:
mfr16
Date:
Thu Oct 06 10:11:06 2016 +0000
Parent:
8:34a48553c0eb
Commit message:
Example to sweep a servo according to MEMS sensors position

Changed in this revision

Servo.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Thu Oct 06 10:11:06 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
--- 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);
   }
 }