This M&M sorter is powered by an iPhone. Its camera is used to read the color of the candy and an array of electromagnet-powered gates to do physical sorting.

Here's a brief explanation of the sorter:

But I don't stop the M&M for colour recognition. Instead I use an iPhone to capture the colour of the M&M as it is in freefall. As it is still falling the iPhone talks to a Bluetooth module attached to an Arduino and that fires off the correct electro magnet controlled gate. This sends the M&M into the correct pot. Even my rough prototype is reasonably fast because the colour recognition and path that the M&M takes down the chute is decided and determined whilst the M&M is moving under gravity.

[Review My Life]