wu

Dependencies:   mbed-rtos mbed

Fork of CCC by kao yi

servo_api.cpp

Committer:
backman
Date:
2014-06-03
Revision:
1:82bc25a7b68b
Child:
9:33b99cb45e99

File content as of revision 1:82bc25a7b68b:

// 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;
    
    }