![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ICRS Eurobot 2013
Dependencies: mbed mbed-rtos Servo QEI
Diff: main.cpp
- Revision:
- 7:4340355261f9
- Parent:
- 6:995b3679155f
- Child:
- 10:1f0cf0182067
diff -r 995b3679155f -r 4340355261f9 main.cpp --- a/main.cpp Fri Apr 05 15:45:00 2013 +0000 +++ b/main.cpp Fri Apr 05 16:37:36 2013 +0000 @@ -67,8 +67,6 @@ #include "Actuators/MainMotors/MainMotor.h" #include "Sensors/Encoders/Encoder.h" #include "Sensors/Colour/Colour.h" -#include "Sensors/Colour/Led.h" -#include "Sensors/Colour/Phototransistor.h" @@ -91,19 +89,19 @@ *****************/ //motortest(); //encodertest(); - motorencodetest(); + //motorencodetest(); //motorencodetestline(); //motorsandservostest(); //armtest(); //motortestline(); - //ledtest(); + ledtest(); //phototransistortest(); //ledphototransistortest(); //colourtest(); // Red SnR too low } void colourtest(){ - Colour c(p9,p10,p20); + Colour c(P_COLOR_SENSOR_BLUE, P_COLOR_SENSOR_RED, P_COLOR_SENSOR_IN); c.Calibrate(); while(true){ wait(0.1); @@ -130,17 +128,17 @@ void ledphototransistortest(){ - Led blue(p9), red(p10); - Phototransistor pt(p20); + DigitalOut blue(P_COLOR_SENSOR_BLUE), red(P_COLOR_SENSOR_RED); + AnalogIn pt(P_COLOR_SENSOR_IN); Serial pc(USBTX, USBRX); while(true){ - blue.on();red.off(); + blue = 1; red = 0; for(int i = 0; i != 5; i++){ wait(0.1); pc.printf("Phototransistor Analog is (blue): %f \n\r", pt.read()); } - blue.off();red.on(); + blue = 0; red = 1; for(int i = 0; i != 5; i++){ wait(0.1); pc.printf("Phototransistor Analog is (red ): %f \n\r", pt.read()); @@ -149,7 +147,7 @@ } void phototransistortest(){ - Phototransistor pt(p20); + AnalogIn pt(P_COLOR_SENSOR_IN); while(true){ wait(0.1); pc.printf("Phototransistor Analog is: %f \n\r", pt.read()); @@ -158,11 +156,11 @@ } void ledtest(){ - Led blue(p9), red(p10); + DigitalOut blue(P_COLOR_SENSOR_BLUE), red(P_COLOR_SENSOR_RED); while(true){ - blue.on();red.off(); + blue = 1; red = 0; wait(0.2); - blue.off();red.on(); + blue = 0; red = 1; wait(0.2); } @@ -249,8 +247,8 @@ } void motorencodetest(){ - Encoder Eright(ENC_RIGHT_A, ENC_RIGHT_B), Eleft(ENC_LEFT_A, ENC_LEFT_B); - MainMotor mright(MOT_RIGHT_A, MOT_RIGHT_B), mleft(MOT_LEFT_A, MOT_LEFT_B); + Encoder Eright(P_ENC_RIGHT_A, P_ENC_RIGHT_B), Eleft(P_ENC_LEFT_A, P_ENC_LEFT_B); + MainMotor mright(P_MOT_RIGHT_A, P_MOT_RIGHT_B), mleft(P_MOT_LEFT_A, P_MOT_LEFT_B); Serial pc(USBTX, USBRX); const float speed = -0.3;