hello

Dependencies:   mbed-rtos mbed

Fork of BX-car by kao yi

Committer:
TonyLin
Date:
Thu Jun 26 14:29:53 2014 +0000
Revision:
10:9f0ce6ba7663
Parent:
9:33b99cb45e99
ok;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
backman 1:82bc25a7b68b 1 // 0~180 angle 1~2ms
backman 1:82bc25a7b68b 2 #include "mbed.h"
backman 1:82bc25a7b68b 3 #include "servo_api.h"
backman 9:33b99cb45e99 4 #define right_end 0.06 //90
backman 9:33b99cb45e99 5 #define left_end 0.11 //-90
backman 1:82bc25a7b68b 6
backman 1:82bc25a7b68b 7 //memory opt
backman 1:82bc25a7b68b 8 // 5 degree seperate
backman 1:82bc25a7b68b 9
TonyLin 10:9f0ce6ba7663 10 BX_servo::BX_servo(void){
TonyLin 10:9f0ce6ba7663 11 angle = 0.085;
backman 1:82bc25a7b68b 12 servo_in= new PwmOut(PTB0);
backman 1:82bc25a7b68b 13 servo_in->period_ms(20);
TonyLin 10:9f0ce6ba7663 14 }
backman 1:82bc25a7b68b 15
TonyLin 10:9f0ce6ba7663 16 float BX_servo::set_angle(float a){
backman 9:33b99cb45e99 17 if(a > left_end)
backman 9:33b99cb45e99 18 a=0.11;
TonyLin 10:9f0ce6ba7663 19 else if(a < right_end)
TonyLin 10:9f0ce6ba7663 20 a=0.06;
TonyLin 10:9f0ce6ba7663 21 angle=a;
TonyLin 10:9f0ce6ba7663 22 *servo_in=angle;
TonyLin 10:9f0ce6ba7663 23
backman 1:82bc25a7b68b 24 return angle;
TonyLin 10:9f0ce6ba7663 25 }