Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MiniProject5_LightTracker by
main.cpp
00001 /*Project to make a servo aim to perpendicular photoresistors at a light source, and display the angle of the source to the servo 00002 Project and code by Preston Stephens and Austin Sloop, Inspired by Dr. Larkin. 1/11/16 00003 */ 00004 00005 #include "mbed.h" 00006 #include "SegDisplay.h" 00007 #include "ServoControl.h" 00008 00009 AnalogIn sensor1(p19); 00010 AnalogIn sensor2(p20); 00011 Serial pc(USBTX, USBRX); 00012 float val1, val2; 00013 00014 int angle; 00015 00016 int main(){ 00017 SegInit(); 00018 ServoInit(); 00019 angle=0; 00020 while(1) 00021 { 00022 val1 = sensor1; 00023 val2 = sensor2; 00024 pc.printf("%.2f \t %.2f\n\r", val1, val2); 00025 if((val1+0.03)>val2){angle=angle+1;} 00026 if(val1<(val2+0.03)){angle=angle-1;} 00027 angle=ServoControl(angle); 00028 SegDisplay(angle); 00029 } 00030 } 00031
Generated on Tue Jul 12 2022 18:05:50 by
1.7.2
