![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final
Fork of MiniProject5_LightTracker by
ServoControl.cpp@14:69cad6d9a2e5, 2016-01-12 (annotated)
- Committer:
- asloop18
- Date:
- Tue Jan 12 01:41:19 2016 +0000
- Revision:
- 14:69cad6d9a2e5
- Parent:
- 13:871d01d0d250
Mission Accomplished; ; Working Version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
asloop18 | 6:992875df04f7 | 1 | //Control Function for servo |
asloop18 | 6:992875df04f7 | 2 | |
asloop18 | 7:30afa5506e74 | 3 | #include "ServoControl.h" |
asloop18 | 6:992875df04f7 | 4 | |
asloop18 | 8:96b30706335b | 5 | PwmOut ServoSignal(p21); //P21 is PWM signal out to servo |
asloop18 | 6:992875df04f7 | 6 | |
asloop18 | 6:992875df04f7 | 7 | void ServoInit(void){ |
asloop18 | 6:992875df04f7 | 8 | ServoSignal.period(0.020); |
asloop18 | 6:992875df04f7 | 9 | } |
asloop18 | 6:992875df04f7 | 10 | |
asloop18 | 14:69cad6d9a2e5 | 11 | int ServoControl(signed int angle){ |
asloop18 | 14:69cad6d9a2e5 | 12 | if(angle<-90){angle=-89;} |
asloop18 | 14:69cad6d9a2e5 | 13 | if(angle>90){angle=89;} |
pstephens18 | 11:7b3d64a66efd | 14 | ServoSignal.pulsewidth_us(1500+10*angle); |
pstephens18 | 13:871d01d0d250 | 15 | return angle; |
asloop18 | 6:992875df04f7 | 16 | } |
asloop18 | 6:992875df04f7 | 17 | |
pstephens18 | 13:871d01d0d250 | 18 | |
pstephens18 | 13:871d01d0d250 | 19 |