Library for using the xbee-compatible Bluetooth Bee Module on an m3pi.

Dependencies:   SensoryTest

Fork of btbee by Nikolas Goldin

Files at this revision

API Documentation at this revision

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);
+        }
+    }
+}
+