Jolyon Hill / ColourSensor

Dependencies:   MCP23S17 PCF8574 TextLCD eeprom mbed-dev

Revision:
9:077d1ad96bca
Parent:
8:e6e4eece90f7
Child:
10:efe8585f7fa4
--- a/main.cpp	Mon Oct 10 15:08:44 2016 +0000
+++ b/main.cpp	Mon Oct 10 15:55:52 2016 +0000
@@ -250,7 +250,7 @@
 
     for (ConfigureSensor = 0; ConfigureSensor < 16; ConfigureSensor++)
     {
-        if((Config[ConfigureSensor]<<1) != NOTUSED)
+        if((Config[ConfigureSensor <<1]) != NOTUSED)
         { 
             SelectSensorPort(ConfigureSensor); //set up H/W mux for this sensor
               
@@ -503,19 +503,25 @@
             
             case STD_YELLOW:
             {
-                if( (GreenProp <= (GreenThreshold-Hysteresis)) && (RedProp >=(RedThreshold+Hysteresis)) ) 
-                {             
-                    LEDColour = YELLOW;
+                if ((RedProp - GreenProp) < 60) //check it is not red!
+                { 
+                    if( (GreenProp <= (GreenThreshold-Hysteresis)) && (RedProp >=(RedThreshold+Hysteresis)) ) 
+                    {             
+                        LEDColour = YELLOW;
+                    }
                 } 
             }
             break;   
             
             case GREEN_YELLOW:
             {
+
                 if( (GreenProp <= (GreenThreshold-Hysteresis)) && (RedProp >=(RedThreshold+Hysteresis)) ) 
                 { //pretty sure it's Yellow
-                
-                    LEDColour = YELLOW;
+                    if ((RedProp - GreenProp) < 60) //check it is not red!
+                    {
+                        LEDColour = YELLOW;
+                    }
                 } 
                 else 
                 {