Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:9bb7e571b55f
- Parent:
- 1:c6e4257722b9
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){}
}