The FollowMeBot follows the user based on the color of his or her shirt. The device hosts a webcam on a servo to find the object and orient the robot. The color is chosen through the user interface with push buttons. Currently, the MATLAB code supports red and green detection. The purpose of FollowMeBot is to be able to follow the user in order to be helpful for daily tasks.

Dependencies:   Rectangle Servo TextLCD mbed

Fork of FollowMeBot3 by Rahul Shetty

Revision:
7:41b5307e4c03
Parent:
6:e97ac3fb8ac5
Child:
8:7758b1db4d5b
--- a/main.cpp	Fri Dec 06 18:04:28 2013 +0000
+++ b/main.cpp	Fri Dec 06 19:06:50 2013 +0000
@@ -46,7 +46,8 @@
 bool colorLost = true; // boolean to represent if the color is confirmed "lost" (aka noColorCounter > NO_COLOR_MAX_COUNT)
 #define GREEN 0
 #define RED 1
-char color = GREEN; // Current color selected by the pushbutton
+int color = GREEN; // Current color selected by the pushbutton
+int colorPast;
 
 // Function Prototypes
 void getXYpos();
@@ -59,10 +60,16 @@
 {
     followMeBot.start();
     servoHor = .5;
+    colorPast = color;
+    greenLED = 1;
     colorPB.fall(&colorSelect);
     while(1) {
         getXYpos();
         moveBot();
+        if(colorPast != color) {
+            pc.printf("%d\n",color);
+            colorPast = color;
+        }
     }
 }
 
@@ -75,7 +82,7 @@
 {
     /*lcd.cls();
     lcd.locate(0,0);
-  lcd.printf("%d;%d;%f", xpos, ypos, servoHor.read());*/
+    lcd.printf("%d;%d;%f", xpos, ypos, servoHor.read());*/
     float temp = 0;
     if(xpos == 0) { // If we recieve a 0 for the location
         if(!colorLost && (++noColorCounter > NO_COLOR_MAX_COUNT)) { // Check to see if we have seen enough to consider the color lost
@@ -126,16 +133,16 @@
         myled = 0;
     }
 
-  /*  float irVal = irSensorFront;
-    lcd.locate(0,0);
-    lcd.printf("irVal: %f", irVal);
-    lcd.locate(0,1);
-    lcd.printf("blob: %d", blobArea);*/
+    /*  float irVal = irSensorFront;
+      lcd.locate(0,0);
+      lcd.printf("irVal: %f", irVal);
+      lcd.locate(0,1);
+      lcd.printf("blob: %d", blobArea);*/
 }
 
 void moveBot()
 {
-   // irVal = irSensorFront;                aaaaaaaaaaa
+    // irVal = irSensorFront;                aaaaaaaaaaa
 
     //
     // colorLost = false;
@@ -159,22 +166,21 @@
             followMeBot.left();
 
         } else if(servoIsInHome() == 0) {//n
-        
+
             //if (irVal < COLLISION_DIST) {
             if (blobArea < 180000) {              //just testing          aaaaaa
                 //lcd.cls();
                 //lcd.printf("forward: %f", irVal);
                 followMeBot.forward();
-            }
-            else {
+            } else {
                 followMeBot.stop();
                 lcd.cls();
                 lcd.locate(0,0);
                 lcd.printf("blobArea: %d ", blobArea);
                 //wait(1);
-               // lcd.printf("stop: %f ", irVal);
-            } 
-            
+                // lcd.printf("stop: %f ", irVal);
+            }
+
             /*
             //followMeBot.changeSpeed(SPEED_CONST/(blobArea/100));
             followMeBot.stop();
@@ -183,8 +189,8 @@
     } else {
         lcd.printf("Color Lost");
         followMeBot.left();
-      //  followMeBot.stop();//n
-       // followMeBot.right();
+        //  followMeBot.stop();//n
+        // followMeBot.right();
     }
 
 }
@@ -200,14 +206,13 @@
     }
 }
 
-void colorSelect(){
+void colorSelect()
+{
     color = !color;
-    pc.putc(color);
-    if(color == GREEN){
+    if(color == GREEN) {
         greenLED = 1;
         redLED = 0;
-    }
-    else{
+    } else {
         greenLED = 0;
         redLED = 1;
     }