Color Sensing and Sorting Robot
Project Constraints:
Accept an input of 10 balls randomly colored red, green, blue, and yellow
Sort and output balls into the four clearly separated color groups
Operate fully autonomously after input
Be designed entirely from scratch, using online resources only for inspiration
Incorporate multiple fabrication techniques, avoiding fully 3D-printed designs
Fabricated and presented within one week
Self-Imposed Constraints:
Only use 2 motors
Wanted to limit reliance on drastic, consistent calibration
Prototyping and Understanding Components
Prototype Design Process:
Two main components to our design
Color sensing wheel where balls were inputted and RGB light intensities were measured
Color sorting chute, which spins to drop the ball into the correct hopper
3D printed and laser cut parts to fit in tandem with PVC piping and various electrical components
Designed a case which would house the color sensor while also limiting access from environmental light, instead having the color sensor take measurements using controlled LEDs instead
Understanding the Electrical Components Used:
Designed our system around a Raspberry Pi and two stepper motors, used for their reliability and accuracy
The TCS3200 RGB Color Sensor detects color by shining light on an object, measuring how much red, green, and blue light reflects back, and converts that light into a frequency signal that the Pi reads to determine the ball color
Code and Programming
Color-sensing-based code
A calibration script collects 15 measurements of red, green, and blue light intensity for each ball color and computes the average RGB values, which are stored as reference measurements for classification
During operation, the system measures the RGB values of each ball positioned under the sensor, computes the Euclidean distance between the measured values and each calibrated reference color, and classifies the ball as the closest match
Movement-based code
The first stepper motor rotates the disk 90 degrees (alternating between 51–52 steps) to position a single ball under the color sensor while simultaneously loading a new ball from the ball magazine
After the ball’s color is classified, the second stepper motor rotates the output chute either clockwise or counterclockwise, choosing the direction that requires the fewest steps
Once the chute is correctly positioned, the first stepper motor rotates another 90 degrees, which releases the classified ball into the chute, moves the next ball into the sensing position, and allows a new ball to drop into the disk
Click to read the codes
Final Design and Demonstration
During our demonstration in class, our robot was able to successfully sort 10 out of 10 randomly ordered balls
We were able to complete all the project constraints, including the two constraints we gave ourselves, using just the two stepper motors and the case, which blocked a majority of the environmental light
The robot was able to work consistently, including multiple trial runs before the demonstration, although occasionally it would have trouble with identifying the yellow balls
The entire sorting process was completed in under two minutes, with room for improvement if we limited the time between movements
10 Colored Balls Sorted
Reflection and Takeaways
This was a really fun and intense project, where the one-week time limit definitely limited some of the design choices we made, but largely just aesthetic and easily fixable things, such as just having taller walls to stop the balls from jumping out
This was also really only of my first times utilizing the benefit of running multiple motors and electrical components off the Raspberry Pi, and was a super cool way to grow my understanding of practical coding and electrical work
Overall, I really have no regrets for this project, as my partner and I worked well together to efficiently design, fabricate, and code the robot to successfully achieve all the goals we had in mind
Practiced several fabrication and prototyping methods in building the robot, including 3D modeling, electronics, Python coding, laser cutting, and basic wood and fabrication skills