Initial attempt at the final chalenge

Dependencies:   ContinuousServo TCS3472_I2C Tach mbed

Revision:
1:d57be3c5dae9
Parent:
0:10faa982ae23
diff -r 10faa982ae23 -r d57be3c5dae9 main.cpp
--- a/main.cpp	Wed Apr 25 14:19:25 2018 +0000
+++ b/main.cpp	Thu Apr 26 14:26:02 2018 +0000
@@ -9,7 +9,7 @@
 ContinuousServo left(p23);
 ContinuousServo right(p26);
 
-//color sensor
+//Color sensor
 PwmOut LB(p25); // PWM out signal to power LED on the sensor
 TCS3472_I2C rgb_sensor( p9, p10 ); // Establish RGB sensor object
 Serial pc(USBTX,USBRX); // Establish serial connection with computer
@@ -26,10 +26,12 @@
 distance = //conversion to analog value;
 
 int main() {
+    //Hall Effect
     hall.mode(PullUp);
     toggle = 1;
     led4 = 0;
     
+    //Color sensor
     rgb_sensor.enablePowerAndRGBC(); // Enable RGB sensor
     rgb_sensor.setIntegrationTime(100); // Set integration time of sensor
     int rgb_data[4]; // declare a 4 element array to store RGB sensor readings
@@ -48,7 +50,7 @@
            led4 = 0;
            counter = counter +1;
            printf("Counter=%d\n",counter);
-           }
+           }//if hall
         if (sonar > distance){
             float speed = 0.5;
             left.speed(speed);
@@ -56,14 +58,16 @@
             if (rgb_data[] > ){//add value for too dark
                 right.speed(-speed - 0.05);
                 left.speed(speed - 0.05);
-                }
+                }//if dark
             else if (rgb_data[] <){//add value for too light
                 right.speed(-speed + 0.05);
                 left.speed(speed + 0.05);
-                }
-            }
+                }//elseif light
+            pc.printf( "unfiltered: %d, red: %d, green: %d, blue: %d \n", rgb_data[0], rgb_data[1], rgb_data[2], rgb_data[3]); 
+            wait(0.05);
+            }//if sonar
         else {
             break;
-            }
-    }
-}
+            }//break
+    }//while(1)
+}//int(main)