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.
Revision 0:086810854173, committed 2014-07-17
- Comitter:
- Privias
- Date:
- Thu Jul 17 12:17:49 2014 +0000
- Commit message:
- Line Trace
;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jul 17 12:17:49 2014 +0000 @@ -0,0 +1,92 @@ +#include "mbed.h" + +PwmOut Right1(p24); +PwmOut Right(p23); +PwmOut Left1(p22); +PwmOut Left(p21); + +AnalogIn ainL1(p17) ; //Left Sencer IN +AnalogIn ainR1(p18) ; //Right Sencor IN +AnalogIn ain(p16); //Sensor +Serial pc(USBTX,USBRX) ; + +int main(){ +wait_ms(2000); +pc.baud ( 115200 ) ; + +Right.period(0.020); +Right1.period(0.020); +Left.period(0.020); +Left1.period(0.020); +double p ; +while(1){ +double L1 = ainL1.read() ; +double adVL = L1*100 ; +double R1 = ainR1.read() ; +double adVR = R1*100 ; +double ai=ain*100; +double t=1.0; + if(ai>60.0){ + p=0.001; + double t=0; + } + if(ai>58.0 && ai<=60.0){ + p=0.005; + } + if(ai>57.0 && ai<=58.0){ + p=0.006; + } + if(ai>55.0 && ai<=57.0){ + p=0.007; + } + if(ai>=50.0 && ai<=55.0){ + p=0.008; + } + if(ai<50.0 && ai<=30.0){ + p=0.010; + } + if(ai<30.0){ + p=0.018; + } //Speed + double p1=0.007; +//double p=0.007; //speed +//Line Found +double adRR= 1.0 ; +double adLL= 2.1; + if(t==0){ + Right.pulsewidth(0.004); + Left.pulsewidth(0.004); + Right1.pulsewidth(0.004); + Left1.pulsewidth(0.004); + } + + if(adVR <adRR && adVL> adLL){ //if Right sensor found Brack Line + Right.pulsewidth(0); + Left1.pulsewidth(0); + Right1.pulsewidth(p1); //Left Motor on AND Roght Motor off + Left.pulsewidth(p1); + + } + if(adVL<adLL && adVR>adRR){ //if Left sensor found Brack Line + Right1.pulsewidth(0); + Left.pulsewidth(0); + Left1.pulsewidth(p1); //Left Motor off AND Roght Motor on + Right.pulsewidth(p1); + } + if(adVR>adRR && adVL>adLL){ // if Vihicle in White Line + Right1.pulsewidth(0); + Left1.pulsewidth(0); + Right.pulsewidth(p); + Left.pulsewidth(p); //Go Strait + } + if(adVR<adRR && adVL<adLL){ // if Vihicle in Black Line + Right.pulsewidth(0); + Left.pulsewidth(0); + Right1.pulsewidth(p); + Left1.pulsewidth(p); //Go Back + wait_ms(50); + } + +pc.printf( "L-Sensor = %4.2f R-Sensor = %4.2f \r\n ", adVL, adVR ) ; + }//while +}//main \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jul 17 12:17:49 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file