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 8:fd8a30a6923d, committed 2014-05-20
- Comitter:
- mmpeter
- Date:
- Tue May 20 13:36:31 2014 +0000
- Parent:
- 7:76a8ae1314a7
- Child:
- 9:6ae4359b73df
- Commit message:
- SensoryTests
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue May 20 13:36:31 2014 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "m3pi_ng.h"
+
+m3pi thinggy;
+
+
+int main() {
+
+ float speed = 0.1;
+ float threshold = 0.01;
+
+ wait(2.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
+ if (position > threshold) {
+ thinggy.right(speed);
+
+ }
+
+ // Line is more than 50% to the left, slow the right motor
+ else if (position < -threshold) {
+ thinggy.left(speed);
+
+ }
+
+ // Line is in the middle
+ else {
+ thinggy.forward(speed);
+ }
+ }
+}
+
