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 18:eddba761c425, committed 2014-05-21
- Comitter:
- mmpeter
- Date:
- Wed May 21 15:00:52 2014 +0000
- Parent:
- 17:a6cb4c42308c
- Commit message:
- Turnarounds
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 21 14:42:33 2014 +0000
+++ b/main.cpp Wed May 21 15:00:52 2014 +0000
@@ -5,10 +5,6 @@
using namespace std;
-void turn_around(int array[5],float speed);
-
-int sensor_refresh(m3pi thinggy, int sensor[5], int x);
-
m3pi thinggy;
@@ -29,31 +25,29 @@
thinggy.sensor_auto_calibrate();
thinggy.calibrated_sensor(sensor);
- returned = sensor[2];
- thinggy.cls();
- thinggy.print("Apple",5);
+ returned = (sensor[1] + sensor[2] + sensor[3])/3;
+
while(1) {
- thinggy.print("Apfel",5);
// change "if" to while
- while(returned < 200){
+ while(returned < 220){
while(sensor[0] < sensor[4]){
- thinggy.left_motor(speed);
- thinggy.right_motor(-speed);
+ thinggy.left_motor(.1);
+ thinggy.right_motor(-.1);
thinggy.calibrated_sensor(sensor);
}
while(sensor[4] > sensor[0]){
- thinggy.left_motor(-speed);
- thinggy.right_motor(speed);
+ thinggy.left_motor(-.1);
+ thinggy.right_motor(.1);
thinggy.calibrated_sensor(sensor);
}
thinggy.calibrated_sensor(sensor);
- returned = sensor[2];
+ returned = (sensor[1] + sensor[2] + sensor[3])/3;
}
- // change "if" to while
- while(returned > 200){
+ // Curves and straightaways
+ while(returned > 220){
float position = thinggy.line_position();
correction = k*(position);
@@ -76,10 +70,10 @@
thinggy.left_motor(speed-correction);
}
thinggy.calibrated_sensor(sensor);
- returned = sensor[2];
+ returned = (sensor[1] + sensor[2] + sensor[3])/3;
}
thinggy.calibrated_sensor(sensor);
- returned = sensor[2];
+ returned = (sensor[1] + sensor[2] + sensor[3])/3;
}
}
