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: ContinuousServo TCS3472_I2C Tach mbed
Revision 1:d57be3c5dae9, committed 2018-04-26
- Comitter:
- m202346
- Date:
- Thu Apr 26 14:26:02 2018 +0000
- Parent:
- 0:10faa982ae23
- Commit message:
- updated a few color sensor things. need gradient value
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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)