ECE B.Tech Advanced

DIY Arduino Based Color Sorter Machine using TCS3200 Color Sensor

Here in this tutorial we will make a color sorting machine using a color sensor TCS3200, some servo motors and Arduino board. This tutorial will include the sorting of colored balls and keeping them in the relevant color box.

  • Suitable forB.Tech ECE students
  • Build time5-7 weeks
  • LevelAdvanced
  • Available atAjvika Labs, Kakinada

About this project

As the name suggests, color sorting is simply to sort the things according to their color. It can be easily done by seeing it but when there are too many things to be sorted and it is a repetitive task then automatic color sorting machines are very useful. These machines have color sensor to sense the color of any objects and after detecting the color servo motor grab the thing and put it into respective box. They can be used in different application areas where color identification, color distinction and color sorting is important. Some of the application areas include Agriculture Industry (Grain Sorting on the basis of color), Food Industry, Diamond and Mining Industry, Recycling etc. The applications are not limited to this and can be further applied to different industries.

Most popular sensor for detecting the colors is TCS3200 color sensor. We previously used TCS3200 sensor with Arduino to get the RGB component (Red, Green, Blue) of any color and also interfaced it with Raspberry Pi for detecting the color of any object.

Here in this tutorial we will make a color sorting machine using a color sensor TCS3200, some servo motors and Arduino board. This tutorial will include the sorting of colored balls and keeping them in the relevant color box. The box will be in the fixed position and the servo motor will be used to move the sorter hand to keep the ball in the relevant box.

We also made a Tomato Sorting Machine using Raspberry Pi, you can check out the demonstration video giveen below.

TCS3200 Color Sensor

How to make the chassis for Color Sorting Robotic Arm

For making the complete setup including chassis, arm, roller, pad, we have used the white Sunboard of 2mm thickness. It is easily available in the stationary stores. We have used paper cutter to cut the Sunboard Sheet and FlexKwik or FeviKwik for joining the different parts. Below are some steps build the Color sorting Arm :

1) Take the Sunboard Sheet.

2) Cut the sunboard sheet into pieces after measuring all sides with scale and marker as shown in the figure.

3) Now hold the two pieces of sunboard together and pour a drop of FeviKwik on it to stick the pieces together. Keep joining the pieces by following the figure.

4) After joining all the pieces together, this color sorting machine will look something like this:

TCS3200 Color Sensor

TCS3200 is a color sensor which can detect any number of colors with right programming. TCS3200 contains RGB (Red Green Blue) arrays. As shown in figure on microscopic level one can see the square boxes inside the eye on sensor. These square boxes are arrays of RGB matrix. Each of these boxes contain three sensors, One is for sensing RED light intensity, One is for sensing GREEN light intensity and the last in for sensing BLUE light intensity.

Each of sensor arrays in these three arrays are selected separately depending on the requirement. Hence it is known as programmable sensor. The module can be featured to sense the particular color and to leave the others. It contains filters for that selection purpose. There is a forth mode called ‘ no filter mode’ in which the sensor detects white light.

Arduino Color Sorter Circuit Diagram

The circuit diagram for this Arduino Color Sorter is pretty easy to make and doesn’t require much connections. The schematic is given below.

This is the circuitry behind the setup of color sorting machine:

Programming Arduino Uno for sorting colourful balls

Programing Arduino UNO is a pretty simple and requires a simple logic to simplify the steps involved in color sorting. Complete program with a demonstration Video is given at the end.

Since the servo motor is used, so the servo library is essential part of the program. Here we are using two servo motors. The first servo will move the colored balls from initial position to TCS3200 detector position and then move to the sorting position where the ball will be dropped. After moving to sorting position, the second servo will drop the ball using its arm to the desired color bucket. See the complete working in the Video given at the end.

The first step will be all library inclusion and define the servo variables.

The TCS3200 color sensor can work without library as there is only need of reading frequency from sensor pin to decide the color. So just define the pin numbers of TCS3200.

Make the select pins as output as this will make the color photodiode high or low and take the Out pin of TCS3200 as input. The OUT pin will provide frequency. Select the scaling of frequency as 20% initially.

The servo motors are connected at Pin 9 and 10 of Arduino. The pickup servo which will pickup the color balls is connected at Pin 9 and the drop servo which will drop the color balls according to the color is connected at Pin10.

Initially the pick servo motor is set in the initially position which in this case is 115 degrees. It may differ and can be customized accordingly. The motor moves after some delay to the detector region and waits for the detection.

The TCS 3200 reads the color and gives the frequency from the Out Pin.

Depending Upon the color detected, the drop servo motor moves with particular angle and drops the color ball to its respective box.

The servo motor returns to the initial position for the next ball to pick.

The function detectColor() is used to measure frequency and compares the color frequency to make the conclusion of color. The result is printed on the serial monitor. Then it returns the color value for cases to move the drop servo motor angle.

Writing to S2 and S3 (LOW, LOW) activates the red photodiodes to take the readings for red color density.

Writing to S2 and S3 (LOW, HIGH) activates the blue photodiodes to take the readings for blue color density.

Writing to S2 and S3 (HIGH, HIGH) activates the green photodiodes to take the readings for green color density.

Then the values are compared to make the color decision. The readings are different for different experimental setup as the detection distance varies for everyone when making the setup.

This finishes the color sorting machine using TCS3200 and Arduino UNO. You can also program it to detect more colors if needed. If you have any doubt or have any suggestion then write to our forum or comment below. Also check the video given below.

Complete Project Code

Technologies used

ArduinoROSPythonRaspberry PiC++OpenCVServo

Hardware components

  • Arduino
  • Servo Motor
  • DC Motor
  • L298N
  • Ultrasonic Sensor
  • ESP32

Software & tools

  • Arduino IDE
  • ROS
  • Python
  • OpenCV
  • VS Code

Project demo video

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.