If you've ever wondered if your bag of M&Ms really did have more red than blue, now's your chance to find out for sure without much effort. Maker and developer Techtronic3D is using our favorite microcontroller, the Raspberry Pi Pico, to operate his custom candy sorter that picks out M&M's one by one to sort them by color.
The device consists of an M&M Minis tube that has been propped upside down and held into place by a custom 3D-printed stand. A little catching mechanism spins up and down to retrieve one candy at a time before presenting it to a camera module. If no candy is detected, the servo will spin back upwards again to try to get another one. Once an M&M is presented, it's then sorted into a colored bin that corresponds with the color of the candy shell.
More than just the M&M Minis tube stand is 3D printed, in fact most of the mounting hardware was designed just for this project. Other components that were printed include the chutes that transport the candy, servo attachments, and the colored bins that catch the candy. The exact filament type used by Techtronic3D isn't confirmed in this video, however, we strongly recommend using a food-safe filament when printing anything that will come into contact with food you plan on eating or serving.
The main board powering this operation appears to be a Raspberry Pi Pico which is receiving power via USB thanks to a nearby laptop. It controls two servos — one for the sorting chute, and one for the candy catcher under the tube. A screen provides a real-time look at what candy is under inspection. It's not clear if the camera input is used for color identification or if another module like a color sensor is used instead.
Unfortunately, Techtronic3D did not provide any source code links so we can only speculate on how this system could be recreated. The biggest mystery lies in the mechanism used to detect colors. Beyond that, a simple Python script can be used to tell the servo under the sorting chute how far to move depending on what color is at hand so it falls into the right bin.
If you want to get a closer look at this Raspberry Pi project in action, you can check it out over at YouTube.
Stay On the Cutting Edge: Get the Tom's Hardware Newsletter
Get Tom's Hardware's best news and in-depth reviews, straight to your inbox.
Ash Hill is a contributing writer for Tom's Hardware with a wealth of experience in the hobby electronics, 3D printing and PCs. She manages the Pi projects of the month and much of our daily Raspberry Pi reporting while also finding the best coupons and deals on all tech.
-
Python in Motion Color sensor, i.e.Reply
https://www.cytron.io/p-apds9960-proximity-light-rgb-and-gesture-sensor