M&M’s Color Sorter

M&M’s Color Sorter

Blue Only Please


Sometime early 2000’s I read about this circuit which involved a color sensor and PIC microcontroller which could do simple detection of color. It worked by shining a white light on a surface, then an array of 64 light sensors with red, green, or blue filters would output a number between 0-255 depending on how much of that color they say – combine all 4 outputs together and you can calculate what the color is.

M&M's Color Sorter Overview of device with servo motor close up

AXE045 Color Sensor


The AXE045 Colour Sensor module is built around a TAOS TCS230 colour sensor. The TAOS TCS230 sensor chip is a ‘programmable colour light-to-frequency
converter’, supplied as a small 8 pin SOIC format chip.

In simple terms this means that it is a sensor that can measure the reflected light intensity from an illuminated sample, by use of an 8 by 8 array of photodiodes. Of these 64 photodiodes, 16 are covered by blue filters, 16 have red filters, 16 have green filters and 16 have no filter.

The red, green and blue (RGB) filters embedded in the TAOS sensor ensure only these colors are exposed to the underlying photodiodes. Therefore, by using a PICAXE microcontroller, the user can programmatically select which colored filtered photodiodes to use at a particular time, and, by cycling through the 4 different options, come to a very good approximation of the RGB content of the sample – hence identifying its color!

M&M's Color Sorter top vie of PIC12F683 microcontroller PICAXE

TCS3200 sensor


The TCS3200 has an array of photodiodes with 4 different filters. A photodiode is simply a semiconductor device that converts light into current. The sensor has:

  • 16 photodiodes with red filter
  • 16 photodiodes with green filter
  • 16 photodiodes with blue filter
  • 16 photodiodes without filter

If you take a closer look at the TCS3200 chip you can see the different filters.

By selectively choosing the photodiode filter’s readings, you’re able to detect the intensity of the different colors. The sensor has a current-to-frequency converter that converts the photodiodes’ readings into a square wave with a frequency that is proportional to the light intensity of the chosen color. This frequency is then, read by the Arduino – this is shown in the figure to the right.

Some content above is with thanks to Rui & Sarah who wrote a great Guide for TCS230/TCS3200

TCS3200 color sensor 8dip close up
Color Sensor Flow diagram

Fun Sorter


The sorter ran on a conveyor belt, but I wanted to put some theater into the system so made a flicking mechanisms which would launch individual M&M’s into a funnel, then onto the conveyor.

I don’t have many photos of the system as it was back early 2000’s but this GIF is quite fun, and at this stage it would launch M&M’s across the room!!

M&M Color Sensor Sender GIF

Newer Modules


Since making this device, there are now many color sensor modules on the market which come as complete ready to use packages, and they don’t cost much, retail price from $8.50!!

Adafruit – RGB Color Sensor with IR filter and White LED

SparkFun – SparkFun RGB Light Sensor

LEGO – MINDSTORMS Education EV3 Color Sensor

DFRobot – TCS3200 Color Sensor/Color Detector