jhonatan llanten / Mbed 2 deprecated sensorcolor

Dependencies:   mbed

Revision:
2:2adef204b5ba
Parent:
1:334b40b47233
--- a/main.cpp	Thu Feb 28 22:33:57 2019 +0000
+++ b/main.cpp	Mon Apr 08 12:36:00 2019 +0000
@@ -54,7 +54,7 @@
 
 Serial command(USBTX, USBRX);
 //                     S0,    S1,   S2,   S3,    OUT
-scolor_TCS3200 scolor(PA_8, PB_10, PB_4, PB_5, PB_3);
+scolor_TCS3200 scolor(PA_8, PB_10, PB_4, PB_5, PA_10);
 
 // definición de las funciones
 void setup_uart();
@@ -69,7 +69,7 @@
     while(1){    
         leer_datos();
         if (cmd==CMD){}
-            leer_color();
+            leer_color(); 
     }    
 }
 
@@ -90,7 +90,10 @@
 
 void leer_color(){
     
- 
+ uint8_t ref;
+ uint8_t rd;
+ uint8_t gr;
+ uint8_t bl;
     
     long     red = scolor.ReadRed();
     long     green = scolor.ReadGreen();
@@ -99,9 +102,32 @@
  
     printf("RED: %5d     GREEN: %5d     BLUE: %5d     CLEAR: %5d    \n ", red, green, blue, clear);
     
-    }
+    
+
+ref = (1/clear);
+rd =(((1/red)*100))/ref);
+gr =((1/green)*100))/ref; 
+bl =((1/blue)*100))/ref;
 
 
 
     
-    
\ No newline at end of file
+    if (rd>gr && rd>bl){
+        printf("el color es rojo");
+            }
+            
+    
+    
+    if (bl>gr && bl>rd){
+        printf("el color es azul");
+            }
+            
+    
+
+    
+    if (gr>rd && gr>bl){
+        printf("el color es verde");
+            }        
+    
+       
+   } 
\ No newline at end of file