A color sorter
ME35 Project 2: The Chromabot
Key skills: color detection algorithms, rapid-prototyping, style
01
Our Goal
Our task description was simple. Our professor would choose ten balls at random. They could be red, blue, green, or yellow. Our machine was to sort these balls by color in four groups using a light sensor that returned scanned RGB values.
To use our machine, you must load our PVC pipe with the balls you want sorted. After scanning the ball at the bottom, we rotate the disk to its "drop position." The ball then lands on a slide, which launches it to its correct end position based on its color.

02
How it's been programmed
The light sensor isn't super reliable. Even if lighting conditions change slightly - suppose another shadow enters, we turn off one switch, or even worse, we move our system one inch in any direction - our sensor values change. We therefore need a strong calibration process.
Every time we start our program, we recalibrate. We get the RGB values of each color and store it as reference. To determine the color of a scanned ball, we find its "vector" distance — with our coordinates being light values returned for R, G, and B — to our reference values. The closest reference color then becomes our guess.
For instance, if red is stored as (1000, 200, 200), green as (2000, 5000, 3000), and we get a reading for (950, 200, 100), we deem the color red. If you are interested, you can check out our code here.

03
Results and Outcomes
The color sorter works 100% 90% of the time. Sometimes, when we flush light into the box, our sensor gets terribly confused, and fails to function as intended. To fix this, ideally, we should enclose the unit. Perhaps we drape it with curtains, or close it within a box - in any case, it would be wise, in a second version, to prevent unwanted light from interfering with our scan.
Other than this, the robot works quite well. The ball-rotating disk does its job, and the slide mechanism is fun and precise!


Please find more photos of videos of our work here!
