Compact Arduino-Controlled Machine Sorts M&Ms by Color

Or perhaps modify it for Skittles to sort the rainbow.

When I was growing up, I remember my dad having a cool party trick: he could identify an M&M candy's color based on its taste. That was quite the feat, because regular M&Ms are all the same flavor. Each candy is a lump of milk chocolate covered in a shell of sugar. The dyes that give each shell its color are supposed to be flavorless. But M&M connoisseurs know that that isn't true. You might even have a favorite color of M&M. If that is the case, this DIY M&M sorting machine should be your next project.

This compact machine has a refillable hopper on top in which you can pour a bag of M&Ms. Once activated, it will proceed to load a single candy into the chute and then check its color. From there, it will deposit the M&M into one of six partitions in a jar with its chromatic companions. The size, shape, and weight of an M&M are fairly consistent and do not differ based on a particular candy's color. That means that a sorting machine like this one needs to actually look at the candy to sort it into the correct bin. You could achieve that with machine learning, but that requires a lot of expensive hardware. This solution is much better.

You can sense an object's color with just a few pieces of inexpensive hardware. If you shine a light onto an object, the amount of light that it reflects is dependent on its color. If you break that down further and shine a series of different wavelengths at the object and measure the reflected light, you can get an accurate sense of the object's color. This machine performs those operations using an Arduino Uno board, an RGB LED, a white LED, and a photoresistor. All of the other components, including a stepper motor and servo motor, are present to actuate the hopper mechanism. The various components of that mechanism are 3D-printable. If you want to build your own, the files, code, and instructions are all available on Instructables. Now you can filter out those nasty red M&Ms and give them to kids who don't yet know any better.

Cameron Coward
Writer for Hackster News. Proud husband and dog dad. Maker and serial hobbyist.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles