Servo

Dependencies:   mbed MODSERIAL Servo FastPWM

Revision:
1:f6898c9b8c44
Parent:
0:60a8a60074a7
Child:
2:381007cb7a70
--- a/main.cpp	Fri Oct 11 08:16:22 2019 +0000
+++ b/main.cpp	Fri Oct 11 08:35:27 2019 +0000
@@ -1,26 +1,19 @@
+// Hello World to sweep a servo through its full range
+ 
 #include "mbed.h"
-//#include "HIDScope.h"
-//#include "QEI.h"
-#include "MODSERIAL.h"
-//#include "BiQuad.h"
-#include "FastPWM.h"
-//#include <math.h>
 #include "Servo.h"
+#include <math.h>
 
 Serial pc(USBTX, USBRX);
 
-Servo servomotor(D3);
-
-int main()
-{ 
-    
-    while( true ) 
-    { 
-        servomotor.write(0.2);
+Servo myservo(D5);
+ 
+int main() 
+{    
+    for(float p=0; p<1.0; p += 0.1) 
+    {
+        myservo = p;
         wait(0.5);
-        servomotor.write(0.4);
-        wait(0.5);
-        pc.printf("hello");
+        pc.printf("hello!");
     }
-    return 0;
 }
\ No newline at end of file