servoding

Dependencies:   mbed Servo

Files at this revision

API Documentation at this revision

Comitter:
S1lverEagle
Date:
Tue Oct 27 09:51:06 2015 +0000
Parent:
1:c6e4257722b9
Commit message:
aangepast aan servo library

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c6e4257722b9 -r 9bb7e571b55f main.cpp
--- a/main.cpp	Fri Oct 23 10:06:36 2015 +0000
+++ b/main.cpp	Tue Oct 27 09:51:06 2015 +0000
@@ -1,26 +1,26 @@
 #include "mbed.h"
-#include "math.h" 
+#include "math.h"
+#include "Servo.h" 
 
 //servo ranges from .6ms to 2.7ms duty cycle in 20ms pwm period
 
-PwmOut servoPwm(D5);
+Servo servoPwm(D5);
 
 double theta1;
 double theta2;
 double theta3;
-double servoPwm.pulsewidth;
 
 Ticker servo;
  
      void servo_control()
 {
      theta3 = 180 - theta1 - theta2;
-     servoPwm.pulsewidth = (0.0021/180)*theta3 + 0.0006;
+     servoPwm.SetPosition = (2100/180)*theta3 + 600;
      }
 
 int main() 
 {   
-      servoPwm.period(0.020);
+      servoPwm.Enable(1650,20000);
         servo.attach(&servo_control,0,02);
         while(true){}
         }