A simple line following program

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
chris
Date:
Tue Nov 02 16:58:25 2010 +0000
Parent:
1:5ddd3faed06d
Child:
3:7f077cf1d755
Commit message:
Changed the instance name from \"pi\" to \"m3pi\", and all reference to it

Changed in this revision

m3pi.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/m3pi.lib	Mon Nov 01 23:21:14 2010 +0000
+++ b/m3pi.lib	Tue Nov 02 16:58:25 2010 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/chris/code/m3pi/#330eb028e85b
+http://mbed.org/users/chris/code/m3pi/#c38d2f980494
--- a/main.cpp	Mon Nov 01 23:21:14 2010 +0000
+++ b/main.cpp	Tue Nov 02 16:58:25 2010 +0000
@@ -2,50 +2,49 @@
 #include "m3pi.h"
 
 BusOut leds(LED1,LED2,LED3,LED4);
-m3pi pi (p27,p9,p10); //nRST, TX, RX
+m3pi m3pi (p27,p9,p10); //nRST, TX, RX
 
 int main() {
 
-    pi.locate(0,1);
-    pi.printf("Line Flw");
+    m3pi.locate(0,1);
+    m3pi.printf("Line Flw");
 
     float position_of_line = 0.0;
-
-    pi.sensor_auto_calibrate();
+    m3pi.sensor_auto_calibrate();
     float speed = 0.4;
 
     while (1) {
 
         // -1.0 is far left, 1.0 is far right
-        position_of_line = pi.line_position();
+        position_of_line = m3pi.line_position();
 
         // Line is more than 75% to the left
         if (position_of_line < -0.25) {
-            pi.left_motor(speed + 0.3);
-            pi.right_motor(speed - 0.3);
+            m3pi.left_motor(speed + 0.3);
+            m3pi.right_motor(speed - 0.3);
             leds = 0xc;
         }
         // Line is more than 25% to the left
         else if (position_of_line < -0.10) {
-            pi.left_motor(speed);
-            pi.right_motor(speed - 0.3);
+            m3pi.left_motor(speed);
+            m3pi.right_motor(speed - 0.3);
             leds = 0x4;
         }
         // Line is more than 75% to the right
         else if (position_of_line > 0.25) {
-            pi.right_motor(speed + 0.3);
-            pi.left_motor(speed - 0.3);
+            m3pi.right_motor(speed + 0.3);
+            m3pi.left_motor(speed - 0.3);
             leds = 0x3;
         }
         // Line is more than 75% to the right
         else if (position_of_line > 0.10) {
-            pi.right_motor(speed);
-            pi.left_motor(speed - 0.3);
+            m3pi.right_motor(speed);
+            m3pi.left_motor(speed - 0.3);
             leds = 0x2;
         }
         // Line is inthe middle
         else {
-            pi.forward(speed);
+            m3pi.forward(speed);
             leds = 0x0;
         }
     }