Sweep a servo according to Proximity sensor measure

Dependencies:   Servo X_NUCLEO_6180XA1 mbed

Fork of HelloWorld_6180XA1 by ST

Files at this revision

API Documentation at this revision

Comitter:
mfr16
Date:
Thu Oct 06 10:50:15 2016 +0000
Parent:
45:97f6ac8f2bb1
Commit message:
Example to sweep a servo according to Proximity sensor measure
;

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
diff -r 97f6ac8f2bb1 -r 43aef8f6e9a0 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Thu Oct 06 10:50:15 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 97f6ac8f2bb1 -r 43aef8f6e9a0 main.cpp
--- a/main.cpp	Tue Sep 27 15:22:33 2016 +0000
+++ b/main.cpp	Thu Oct 06 10:50:15 2016 +0000
@@ -5,6 +5,10 @@
 #include <stdio.h>
 #include <assert.h>
 
+#include "Servo.h"
+
+Servo myservo(D3);
+
 /* This VL6180X Expansion board test application performs a range measurement and als measurement in polling mode
    on the onboard embedded top sensor. 
    The result of both the measures are printed on the serial over.  
@@ -34,6 +38,7 @@
    {
       board->sensor_top->GetDistance(&dist);	
       board->sensor_top->GetLux(&lux);
+      myservo = (255.0-dist)/255.0;
       printf ("Distance: %d, Lux: %d\n\r",dist, lux);      	
    }  
 }