This machine sorts candy by color. It separates different colored Skittles and M&Ms pieces and puts them into individual cups. The machine is fully automated and will sort an entire 1.5kg/56oz bag in approx. 5 minutes. It is built on an ATmega328 microcontroller (Arduino Uno), RGB color sensor, IR distance sensor, two servos, plastic frame tubes and a few custom designed 3D printed parts. The processing is structured around pseudo-realtime programming which makes the system responsive and keeps it running smoothly. Each process in the system is designed around the notion of event driven finite-state machine (FSM) execution.
https://beta.ivc.no/wiki/index.php/Skittles_M&M’s_Sorting_Machine