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.
Dependencies: mbed 3875_Individualproject
Diff: main/main.cpp
- Revision:
- 3:a5e06482462e
- Parent:
- 2:940e46e21353
- Child:
- 4:38c29dbc5953
--- a/main/main.cpp Thu Feb 13 15:28:21 2020 +0000 +++ b/main/main.cpp Thu Feb 13 16:34:40 2020 +0000 @@ -45,6 +45,7 @@ char path[100]; int path_length = 0; unsigned int *sensor; +float speed; // Main @@ -52,7 +53,7 @@ { init(); calibrate(); - float speed = (pot_S*0.4)+0.1; // have it so max is 0.5 and min is 0.1 + speed = (pot_S*0.4)+0.1; // have it so max is 0.5 and min is 0.1 float proportional = 0.0; float prev_proportional = 0.0; @@ -178,35 +179,33 @@ void left() { leds = 0b1100; - //while (sensor[0] > 500) { robot.scan(); } - wait(0.2); + + while (sensor[0] > 500) { robot.scan(); } + + if (speed <= 0.25) { wait(0.1); } + robot.spin_left(0.2); - wait(0.32); // this wait could be replaced with while statements that wait for sensor3 to become untrigger then retriggered) - /*while (sensor[3] > 500) { - robot.scan(); - wait(0.1); - while (sensor[3] < 500) { - robot.scan(); - wait(0.1); - } - }*/ - //robot.scan(); - //robot.follow_line(); + wait(0.1); + + while (sensor[1] < 500) { robot.scan(); } + + while (sensor[1] > 500) { robot.scan(); } } void right() { leds = 0b0011; - //while (sensor[0] > 500) { robot.scan(); } - wait(0.2); + + while (sensor[4] > 500) { robot.scan(); } + + if (speed <= 0.25) { wait(0.1); } + robot.spin_right(0.2); - wait(0.32); - /*while (sensor[1] > 500) { - while (sensor[1] < 500) { - } - }*/ - //robot.scan(); - //robot.follow_line(); + wait(0.1); + + while (sensor[3] < 500) { robot.scan(); } + + while (sensor[3] > 500) { robot.scan(); } } void back() @@ -215,11 +214,10 @@ robot.reverse(0.2); wait(0.15); robot.spin_right(0.2); - wait(0.6); - /* - while (sensor[1] < 500) { - } - */ + + while (sensor[3] < 500) { robot.scan(); } + + while (sensor[3] > 500) { robot.scan(); } } void goal()