Servo example

Dependencies:   Stepper mbed Servo UniServ

Revision:
0:7e83e43a76b2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 25 13:31:53 2019 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "UniServ.h"
+#include "Servo.h"
+#include "Stepper.h"
+
+// test code for servo and stepper motors
+
+Servo  S0(PB_2);
+Servo  S1(PC_8);
+Servo  S2(PC_6);
+Servo  S3(PB_12);
+
+int main()
+{
+
+    // initialise and test Servo
+    S0.Enable(1000,20000);
+    S1.Enable(1000,20000);
+    S2.Enable(1000,20000);
+    S3.Enable(1000,20000);
+
+    printf("initialization succesfull\r\n");
+    /*
+    for (int pos = 775; pos < 2150; pos += 25) {
+        S2.SetPosition(pos);
+        printf("pos = %d\r\n",pos);
+        wait(0.1);
+    }*/
+    
+    int i = 500;
+    
+    while(1) {
+        /*
+        S2.SetPosition(1500);
+        pwm_motor3.write(0.1f);
+        wait(1);
+        S2.SetPosition(900);
+        pwm_motor3.write(0.0f);
+        wait(1);
+        */
+        printf("position %d\r\n",i);
+        S2.SetPosition(i);
+        i=i+50;
+        
+        wait(1.0f);
+        
+    }
+}