A new machine solely designed to work out the colours of M&M’s and then direct each one into a separate chute, is using an iPhone to do the job. According to ReviewMyLife, built into the machine is an iPhone dock, that connects via Bluetooth with an Arduino unit in order to sort the colours it recognises as they fall past the smartphone.
As each colour passes by the device it activates the Arduino, which in turn uses a magnet to open to hatch to the correct chute and thereby sorting them into colours.
M&M sorting machine. A high torque motor rotates a plate that sends M&M through a hole one at a time. As the M&Ms fall an iPhone distinguish the colours. The iPhone communicates with an Arduino via a bluetooth board, and the Arduino then uses a relay to fire off electromagnet controlled gates to send the M&Ms into the correct chute.
Check out the following video of a prototype for a better idea: