AVGG

Dependencies:   mbed

Fork of 7_7Boboobooo by 譯文 張

Committer:
physicsgood
Date:
Thu Jul 10 16:38:27 2014 +0000
Revision:
15:7f21c08be164
Parent:
9:a891053657f3
QQQQQQQQ

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"
even 9:a891053657f3 4 #define right_end 0.054 //90
even 9:a891053657f3 5 #define left_end 0.025 //-90
backman 1:82bc25a7b68b 6
backman 1:82bc25a7b68b 7 //memory opt
backman 1:82bc25a7b68b 8 // 5 degree seperate
physicsgood 6:b046d6ff3745 9 BX_servo::BX_servo(void)
physicsgood 6:b046d6ff3745 10 {
physicsgood 6:b046d6ff3745 11 angle = 0;
physicsgood 6:b046d6ff3745 12 servo_in= new PwmOut(PTB0);
physicsgood 6:b046d6ff3745 13 servo_in->period_ms(20);
physicsgood 6:b046d6ff3745 14 }
backman 1:82bc25a7b68b 15
physicsgood 6:b046d6ff3745 16 float BX_servo::set_angle(float a)
physicsgood 6:b046d6ff3745 17 {
backman 1:82bc25a7b68b 18
physicsgood 6:b046d6ff3745 19 if( a<left_end )
physicsgood 6:b046d6ff3745 20 a=left_end;
physicsgood 6:b046d6ff3745 21 else if(a>right_end)
physicsgood 6:b046d6ff3745 22 a=right_end;
physicsgood 6:b046d6ff3745 23 angle=a;
physicsgood 6:b046d6ff3745 24 *servo_in=angle;
backman 1:82bc25a7b68b 25
backman 1:82bc25a7b68b 26 return angle;
physicsgood 6:b046d6ff3745 27 }