servo motor

Dependencies:   mbed QEI Servo HIDScope MODSERIAL FXOS8700Q FastPWM

Revision:
0:fd4dd111fbd9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 29 13:36:02 2019 +0000
@@ -0,0 +1,29 @@
+#include "Servo.h"
+#include "mbed.h"
+#include "MODSERIAL.h"
+#include "FastPWM.h"
+
+// PC connection
+MODSERIAL pc(USBTX, USBRX);
+
+int main()
+{
+pc.baud(115200);
+pc.printf("starting 1");
+Servo myservo(D3);
+int pos1 = 1000;
+int posperiod = 20000;
+myservo.Enable(pos1,posperiod);
+
+while(true) {
+    pc.printf("starting");
+    for (int pos = 1000; pos < 2000; pos += 25) {
+        myservo.SetPosition(pos);  
+        wait_ms(20);
+    }
+    for (int pos = 2000; pos > 1000; pos -= 25) {
+        myservo.SetPosition(pos); 
+        wait_ms(20); 
+        }
+    }
+    }