This is an old project using a BASIC Stamp, but I still wanted to get it up here “Identifying color is easy with the new Texas Advanced Optical Systems TCS230 frequency to color sensor. This is a high-sensitivity low-noise light-to-voltage optical converter that incorporates on board blue, green, and red optical filters. The sensor combines a photodiode and an amplifier on a single monolithic CMOS integrated circuit with a color filter over the photodiode. What’s really neat about this sensor is that it provides standard RGB color values with 90% accuracy.” Link.
HOW TO – Make a M&M Sorter