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.
Diff: main.cpp
- Revision:
- 4:d53cb2045ee8
- Parent:
- 3:1db119f74ecb
- Child:
- 5:a7949ddab560
diff -r 1db119f74ecb -r d53cb2045ee8 main.cpp
--- a/main.cpp Thu Jun 29 09:49:32 2017 +0000
+++ b/main.cpp Tue Nov 19 10:27:17 2019 +0000
@@ -46,7 +46,7 @@
float speed = 0.25;
// threshold to determine when over line
- float threshold = 0.2;
+ float threshold = 0.1;
// value to increase/decrease speed by
float power = 0.05;
@@ -61,21 +61,21 @@
float position = robot.calc_line_position(values);
// number is negative when the line is to the left. Need to turn left
- if (position < threshold) {
+ if (position < -threshold) {
// slow down left, speed up right
-
+ robot.motors(0,speed);
// ADD CODE HERE TO CONTROL MOTORS
}
// number is positive when the line is to the right. Need to turn right
else if (position > threshold) {
// slow down right, speed up left
-
+ robot.motors(speed,0);
// ADD CODE HERE TO CONTROL MOTORS
}
// else over the line
else {
// drive straight ahead
-
+ robot.motors(speed,speed);
// ADD CODE HERE TO CONTROL MOTORS
}