![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final
Fork of MiniProject5_LightTracker by
main.cpp
- Committer:
- asloop18
- Date:
- 2016-01-12
- Revision:
- 14:69cad6d9a2e5
- Parent:
- 13:871d01d0d250
File content as of revision 14:69cad6d9a2e5:
/*Project to make a servo aim to perpendicular photoresistors at a light source, and display the angle of the source to the servo Project and code by Preston Stephens and Austin Sloop, Inspired by Dr. Larkin. 1/11/16 */ #include "mbed.h" #include "SegDisplay.h" #include "ServoControl.h" AnalogIn sensor1(p19); AnalogIn sensor2(p20); Serial pc(USBTX, USBRX); float val1, val2; int angle; int main(){ SegInit(); ServoInit(); angle=0; while(1) { val1 = sensor1; val2 = sensor2; pc.printf("%.2f \t %.2f\n\r", val1, val2); if((val1+0.03)>val2){angle=angle+1;} if(val1<(val2+0.03)){angle=angle-1;} angle=ServoControl(angle); SegDisplay(angle); } }