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 0:10faa982ae23, committed 2018-04-25
- Comitter:
- nbchaskin
- Date:
- Wed Apr 25 14:19:25 2018 +0000
- Child:
- 1:d57be3c5dae9
- Child:
- 2:141024530b2f
- Commit message:
- Rough initial attempt
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ContinuousServo.lib Wed Apr 25 14:19:25 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jdonnal/code/ContinuousServo/#d6371727ce0c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TCS3472_I2C.lib Wed Apr 25 14:19:25 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/karlmaxwell67/code/TCS3472_I2C/#6d5bb4ad7d6e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tach.lib Wed Apr 25 14:19:25 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jdonnal/code/Tach/#c165325c9e3f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Apr 25 14:19:25 2018 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+#include "ContinuousServo.h"
+#include "Tach.h"
+#include "TCS3472_I2C.h"
+//driving
+Tach tLeft(p17,64);
+Tach tRight(p13,64);
+
+ContinuousServo left(p23);
+ContinuousServo right(p26);
+
+//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
+
+//Hall effect
+InterruptIn hall(p21);
+DigitalOut led4(LED4);
+DigitalOut toggle(p22);
+int counter = 0;
+
+//need distance to stop
+float distance;
+distance = //inches;
+distance = //conversion to analog value;
+
+int main() {
+ hall.mode(PullUp);
+ toggle = 1;
+ led4 = 0;
+
+ 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
+ float PWMbrightness = 1.0; // float specifying brightness of LED (between 0.0 and 1.0)
+
+ while(1) {
+ LB = PWMbrightness; // set brightness of sensor LED
+ rgb_sensor.getAllColors( rgb_data ); // read the sensor to get red, green, and blue color data along with overall brightness
+
+ if(hall == 1){
+ led4 = 1;
+ wait(0.4);
+ toggle = 0;
+ wait(0.1);
+ toggle = 1;
+ led4 = 0;
+ counter = counter +1;
+ printf("Counter=%d\n",counter);
+ }
+ if (sonar > distance){
+ float speed = 0.5;
+ left.speed(speed);
+ right.speed(-speed);
+ if (rgb_data[] > ){//add value for too dark
+ right.speed(-speed - 0.05);
+ left.speed(speed - 0.05);
+ }
+ else if (rgb_data[] <){//add value for too light
+ right.speed(-speed + 0.05);
+ left.speed(speed + 0.05);
+ }
+ }
+ else {
+ break;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Apr 25 14:19:25 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee \ No newline at end of file