For color detection you usually need a color sensor. Here you will see that it is possible to detect a color by using only RGB LED and a photo-resistor.
The idea is that the amount of light reflected from an object is of maximum value when the object is the same color as the light source. That means that with RGB LED and a photo-resistor it is possible to detect a full color spectrum. Microchip PIC16F887 microcontroller is used in this project only because of that. If it is necessary to detect only one color than the microcontroller is not needed, only the circuit with fixed values. This is a very good explanation of a simple color sensor and it could be used in robotic sorting.