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.
Fork of Boboobooov5 by
Diff: servo_api.cpp
- Revision:
- 1:82bc25a7b68b
- Child:
- 9:33b99cb45e99
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/servo_api.cpp Tue Jun 03 15:53:55 2014 +0000
@@ -0,0 +1,50 @@
+// 0~180 angle 1~2ms
+#include "mbed.h"
+#include "servo_api.h"
+
+
+#define right_end 0.05 //90
+
+#define left_end 0.1 //-90
+
+//memory opt
+// 5 degree seperate
+
+
+
+BX_servo::BX_servo(void){
+
+
+ angle = 0;
+
+ servo_in= new PwmOut(PTB0);
+
+ servo_in->period_ms(20);
+
+ for(int i=0;i<37;i++){
+
+ angle_level[i]=i*(0.05/36)+right_end;
+ }
+
+ *servo_in =angle_level[18];
+
+
+ }
+
+
+
+
+
+
+int BX_servo::set_angle(int a){
+
+
+ angle=a;
+
+ *servo_in=angle_level[18+a/5];
+
+
+
+ return angle;
+
+ }
\ No newline at end of file
