Introduction: Arduino Brick Color Sorter Project

In this Arduino Tutorial, we will learn how to detect colors of my toy brick by using Arduino and the TCS3200 Color Sensor. You can read the written tutorial below for more details.


Arduino Leonardo x 1

TCS3200 x 1

Lots of cardboard

180 Servo x 2


A extra box

Step 1: First, Let Me Tell You How It Works.

I take research to what this sensor is, and this is a short definition. The TCS32000 senses color light with the help of an 8 x 8 array of photodiodes. Then using a Current-to-Frequency Converter the readings from the photodiodes are converted into a square wave with a frequency directly proportional to the light intensity. Finally, using the Arduino Board, we can read the square wave output and get the results for the color.

If we take a closer look at the sensor we can see how it detects various colors. The photodiodes have three different color filters. Sixteen of them have red filters, another 16 have green filters, another 16 have blue filters and the other 16 photodiodes are clear with no filters.

Step 2: Second, It Is All About the Coding.

Step 3: Third, I Am Going to Explain My Code.

First parts of my code we need to define the pins to which the sensor is connected to our board. And we are going to define a variable for reading the frequency.

In the setup section, we need to define the four control pins as outputs and the sensor output as an Arduino input. And also the servo we are using is gonna set up as an output pin.

In the loop section, we will start with reading the red filtered photodiodes. For that purpose, we will set the two control pins S2 and S3 to lower logic level. Then using the “pulseIn()” function we will read the output frequency and put it into the variable “frequency”. Using the Serial. Print () function we will print the result on the serial monitor. The same procedure goes for the two other colors, we just need to adjust the control pins for the appropriate color. Later on, we use the information from frequency and frequency1 as the conditional number in our if, then turn the servo into the right place.

Step 4: Then, Here Is About the Design

The working to the machine is very simple, it only got three steps:

1. Firstly, the colored brick which are held in the charger drop into the platform attached to the top servo motor.

2. Then the servo motor rotates and brings the brick to the color sensor, which detects its color with red, yellow, and blue bricks.

3. After that the bottom servo motor rotates to the particular position and then the top servo motor rotates again till the brick drop into the guide rail.

Step 5: Finally, Finish the Project, and Let the Kids Play With It.

After uploading the code I secured the Arduino Board using a glue gun.Then using a transparent plastic bottle I made the charger and together with the top part glued it to assembly and finished the project. After all, it is a great experience to have this chance to make this project. And I wish that you can learn things through this tutorial. And I am free to ask any question in the comments section below. Thankyou.