servo

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
dantg
Date:
Tue Oct 30 12:54:24 2018 +0000
Commit message:
Servo with Sensor;

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
mbed.bld 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	Tue Oct 30 12:54:24 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 30 12:54:24 2018 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "Servo.h"
+
+Serial pc(USBTX, USBRX); // USB serial interface
+Servo my_srv(p21); // continuous rotation hobby servo
+DigitalIn snsr30(p17);
+DigitalIn snsr150(p18);
+#define CR_SCALE 12.0
+int main() {
+ // set the USB serial interface baud rate
+ pc.baud(921600);
+
+ my_srv.calibrate(0.001,45);
+ while(1) {
+        if(snsr30 > 0.8) {
+            my_srv.write(0.1666666);
+            }
+            wait(0.5);
+        else {
+            my_srv.write(0.5);
+            }
+            wait(0.5);
+        if(snsr150 > 0.8) {
+            my_srv.write(0.8333333);
+            }
+            wait(0.5);
+        else {
+            my_srv.write(0.5);
+            }
+            wait(0.5);
+ }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 30 12:54:24 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file