2014 Eurobot fork

Dependencies:   mbed-rtos mbed QEI

Revision:
11:bbddc908c78c
Parent:
10:1f0cf0182067
Child:
12:76c9915db820
Child:
13:d4b5851742a3
--- a/main.cpp	Fri Apr 05 16:40:52 2013 +0000
+++ b/main.cpp	Fri Apr 05 17:47:06 2013 +0000
@@ -36,33 +36,30 @@
 30: Color sensor BLUE LED
 
 */
-
-#define P_SERVO_LOWER_ARM p5
-#define P_SERVO_UPPER_ARM p6
-
-#define P_SERIAL_RX p14
-#define P_DISTANCE_SENSOR p15
-
-#define P_COLOR_SENSOR_IN p20
-
-#define P_MOT_RIGHT_A p21
-#define P_MOT_RIGHT_B p22
-#define P_MOT_LEFT_A p23
-#define P_MOT_LEFT_B p24
-
-#define P_ENC_RIGHT_A p28
-#define P_ENC_RIGHT_B p27
-#define P_ENC_LEFT_A p25
-#define P_ENC_LEFT_B p26
-
-#define P_COLOR_SENSOR_RED p29
-#define P_COLOR_SENSOR_BLUE p30
-
-
-
 #include "mbed.h"
 Serial pc(USBTX, USBRX);
 
+const PinName P_SERVO_LOWER_ARM = p5;
+const PinName P_SERVO_UPPER_ARM = p6;
+
+const PinName P_SERIAL_RX       = p14;
+const PinName P_DISTANCE_SENSOR = p15;
+
+const PinName P_COLOR_SENSOR_IN = p20;
+
+const PinName P_MOT_RIGHT_A     = p21;
+const PinName P_MOT_RIGHT_B     = p22;
+const PinName P_MOT_LEFT_A      = p23;
+const PinName P_MOT_LEFT_B      = p24;
+
+const PinName P_ENC_RIGHT_A     = p28;
+const PinName P_ENC_RIGHT_B     = p27;
+const PinName P_ENC_LEFT_A      = p25;
+const PinName P_ENC_LEFT_B      = p26;
+
+const PinName P_COLOR_SENSOR_RED = p29;
+const PinName P_COLOR_SENSOR_BLUE = p30;
+
 #include "Actuators/Arms/Arm.h"
 #include "Actuators/MainMotors/MainMotor.h"
 #include "Sensors/Encoders/Encoder.h"
@@ -96,9 +93,9 @@
     //motorsandservostest();
     //armtest();
     //motortestline();
-    ledtest();
+    //ledtest();
     //phototransistortest();
-    //ledphototransistortest();
+    ledphototransistortest();
     //colourtest(); // Red SnR too low
     cakesensortest();
 }
@@ -107,7 +104,7 @@
     wait(1);
     pc.printf("cakesensortest");
     
-    CakeSensor cs(p20);
+    CakeSensor cs(P_COLOR_SENSOR_IN);
     while(true){
         wait(0.1);
         pc.printf("distance: %f\t %f\r\n", cs.Distance(),cs.Distanceincm());
@@ -147,6 +144,12 @@
     Serial pc(USBTX, USBRX);
 
     while(true){
+        blue = 0; red = 0;
+        for(int i = 0; i != 5; i++){
+            wait(0.1);
+            pc.printf("Phototransistor Analog is (none): %f \n\r", pt.read());
+        }
+    
         blue = 1; red = 0;
         for(int i = 0; i != 5; i++){
             wait(0.1);
@@ -157,6 +160,11 @@
             wait(0.1);
             pc.printf("Phototransistor Analog is (red ): %f \n\r", pt.read());
         }
+        blue = 1; red = 1;
+        for(int i = 0; i != 5; i++){
+            wait(0.1);
+            pc.printf("Phototransistor Analog is (both): %f \n\r", pt.read());
+        }
     } 
 }