Tony Lin
/
BX-car
hello
Fork of BX-car by
Diff: servo_api.cpp
- Revision:
- 10:9f0ce6ba7663
- Parent:
- 9:33b99cb45e99
--- a/servo_api.cpp Tue Jun 24 10:06:54 2014 +0000 +++ b/servo_api.cpp Thu Jun 26 14:29:53 2014 +0000 @@ -1,49 +1,25 @@ // 0~180 angle 1~2ms #include "mbed.h" #include "servo_api.h" - - #define right_end 0.06 //90 - #define left_end 0.11 //-90 //memory opt // 5 degree seperate - - -BX_servo::BX_servo(void){ - - - angle = 0; - +BX_servo::BX_servo(void){ + angle = 0.085; servo_in= new PwmOut(PTB0); - servo_in->period_ms(20); - - - - } - +} - - - - -float BX_servo::set_angle(float a){ - +float BX_servo::set_angle(float a){ if(a > left_end) a=0.11; - else if(a< 0.06) - a=0.06; - - - angle=a; - - *servo_in=angle; - - - + else if(a < right_end) + a=0.06; + angle=a; + *servo_in=angle; + return angle; - - } \ No newline at end of file +} \ No newline at end of file