Final

Dependencies:   mbed

Fork of MiniProject5_LightTracker by Austin Sloop

ServoControl.cpp

Committer:
pstephens18
Date:
2016-01-12
Revision:
13:871d01d0d250
Parent:
11:7b3d64a66efd
Child:
14:69cad6d9a2e5

File content as of revision 13:871d01d0d250:

//Control Function for servo

#include "ServoControl.h"

PwmOut ServoSignal(p21);            //P21 is PWM signal out to servo 

void ServoInit(void){
    ServoSignal.period(0.020);
}

int ServoControl(int angle){
    if(angle<-90){angle=-90;}
    if(angle>90){angle=90;}
    ServoSignal.pulsewidth_us(1500+10*angle); 
    return angle;
}