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: SensoryTest
Fork of btbee by
Revision 10:7ef481d28dcd, committed 2014-05-20
- Comitter:
- mmpeter
- Date:
- Tue May 20 14:33:23 2014 +0000
- Parent:
- 9:6ae4359b73df
- Child:
- 11:45172e28ecb2
- Commit message:
- testing
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue May 20 13:53:38 2014 +0000
+++ b/main.cpp Tue May 20 14:33:23 2014 +0000
@@ -7,31 +7,34 @@
int main() {
float speed = 0.1;
- float threshold = 0.1;
+ float correction = 0.5;
+ float threshold = 0.5;
thinggy.locate(0,1);
thinggy.printf("Line Flw");
- wait(2.0);
+ wait(1.0);
thinggy.sensor_auto_calibrate();
while(1) {
// -1.0 is far left, 1.0 is far right, 0.0 in the middle
float position= thinggy.line_position();
- // Line is more than the threshold to the right, slow the left motor
+ // Too far to the right--slow left motor
if (position > threshold) {
- thinggy.right(speed);
+ thinggy.right_motor(speed);
+ thinggy.left_motor(speed-correction);
}
- // Line is more than 50% to the left, slow the right motor
+ // Too far to the left--slow right motor
else if (position < -threshold) {
thinggy.left_motor(speed);
+ thinggy.right_motor(speed-correction);
}
- // Line is in the middle
+ // Default: Centered
else {
thinggy.forward(speed);
}
