Colored Ball Sorter with PiCam and OpenCV

March 15, 2024

If you have been following my posts, you would know I am an Electrical Engineering student at BCIT. In my last post, I talked about my course ELEX 4618 (Object Oriented Program Design), and some of the weekly labs I worked on. One of those labs (#8) required us to make a colored ball sorter. It had to be programmed in C++ to run on a Raspberry Pi that uses PiCam and OpenCV to detect colors and the pigpio library to enable us to use the Pi GPIO pins to interact with other hardware. In Lab #9, we added functionality so this device can be controlled and sends a video stream over the network. 

User Interface built with CVUI.

For design inspiration for this project, I came across this Skittles sorter built using an Arduino and a color sensor. Luckily, the creator uploaded his STL files to printables.com, which I was able to modify for my 15 mm diameter balls. The original model only has a half-rotating disc as the creator used a servo motor that only sweeps 180°, I used the same servo model (MG995) but I converted the servo to a continuous rotation servo, allowing me to spin it full 360° and making the sorting process much faster. For the second servo, I used an unmodified SG90 servo motor. I have uploaded my remixed files here, feel free to modify or print this model.

Posted in UncategorizedTags:
Related Posts

In the BEng EE program at BCIT we have two 4-week summer terms. One of them is taken right after the first year and the second one can be taken after the completion of the second or third year. I recently completed that second…

During my second year of EE at BCIT, I took the course ELEX 3305 (Microcontroller Systems), where we learned to program a Texas Instruments TM4C123G microcontroller in C++. We also purchased a (TI) Education Boosterpack, which is an add-on board with various analog and…

I learned Schematic and PCB design using Altium Designer at BCIT. My plan was to do some more practice over the Summer. To my surprise, a few weeks after the end of the course our accounts were disabled even though I thought we had…

Write a comment