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 10:57a0c57cabac, committed 2016-10-16
- Comitter:
- csellier
- Date:
- Sun Oct 16 18:03:21 2016 +0000
- Parent:
- 9:a543d0cdfce9
- Child:
- 11:055ee1a3cb75
- Commit message:
- Program collision avoidance 90 90 90, missing line-following feature
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Oct 16 16:36:56 2016 +0000 +++ b/main.cpp Sun Oct 16 18:03:21 2016 +0000 @@ -27,9 +27,9 @@ int main() { float front; float left; - float right; - float LDRvalueleft; - float LDRvalueright; +// float right; +// float LDRvalueleft; +// float LDRvalueright; // set the USB serial interface baud rate pc.baud(921600); @@ -40,9 +40,9 @@ // Auto drive : the car will avoid all obstacles aroiund it and get away from them front = IRfront.read(); left = IRleft.read(); - right = IRright.read(); - LDRvalueright = LDRright.read(); - LDRvalueleft = LDRleft.read(); //output voltage of the LDR used for line following feature +// right = IRright.read(); +// LDRvalueright = LDRright.read(); +// LDRvalueleft = LDRleft.read(); //output voltage of the LDR used for line following feature /***************************************************************************** / if (front > DISTANCE) { Collision avoidance system only,the robot will move away from an obstacle/wall if getting to close to it @@ -62,7 +62,8 @@ / ServoLeft.write(0.4); / } / } - /*****************************************************************************/ + *****************************************************************************/ + //Turn both LED's on for the line following feature LEDleft=1; LEDright=1; @@ -76,6 +77,10 @@ ServoRight.write(0.5); // stop servoright ServoLeft.write(0.4); // turn on servoleft wait(2.0); //wait 2 seconds to allow the robot to turn approximately 90 degrees + // go straight for a second to establish separation from the object + ServoRight.write(0.6); + ServoLeft.write(0.4); + wait(1.0); if (left > DISTANCE) { // keep going straight for 1 second ServoRight.write(0.6); // write to the continuous rotation servo1 @@ -98,12 +103,13 @@ ServoRight.write(0.6); ServoLeft.write(0.5); wait(2.0); //wait 2 seconds to allow robot to turn 90 degrees + ServoRight.write(0.6); //after turning 90 deg turn both servos on so the robot goes straight ahead + ServoLeft.write(0.4); } } - - - - } + } + else if (front < DISTANCE) { + //follow line + } } - - +} \ No newline at end of file