Arduino Color Sensor Project using TCS230

This article shows you how to make arduino color sensor project using TCS230 color sensor. This project can detect almost all color according to their wave length and display it on 16×2 LCD. If we talk about the application of this project, you can use in color shorting or color matching projects, line following robot (if path is other than black and white), multi-color strip reading etc.

What is TCS230 Color Sensor?

This module consists 8×8 array of photodiode which detect the color and produce corresponding frequency (Square wave). So, we can say that color sensor module TCS230 is light to frequency converter. As the frequency is of square wave type arduino can read it through its digital pin directly i.e. we do not need ADC. There are total number of 64 photodiode (8×8 = 64) which is divided into for color category i.e. RED Filter, GREEN Filter, BLUE Filter and no COLOR Filter. Each category consists 16 numbers of photodiode. This photo diode generate frequency according to color it detects.

author prototype of arduino color sensor project

At first let’s see the pin configuration of TCS230. Thera are total 8 numbers of pin out of which two are for power supply pin and 6 are for input and output pin.

pin description of TCS230 color sensor

Working principle of detecting the color

The three colors Red, Blue and Green (RGB) wavelengths are known as primary colors because these can be combined or added together in different proportions to produce almost all other colors. Let’s take an example, white light can be produced by mixing 30% red, 59% Green and 11% blue. Similarly, all other colors can be produced by suitably mixing the primary colors as shown in figure below.

mixing of color

From above we can conclude that every other color is either additive mixture or subtractive mixture of these three-primary color. By using this same method, we are going to detect multiple color. In order to read these colors, we have to see the nature of output from pin S2 and S3. So, for easy understanding let’s make a truth table for color detection.

truth table of input switch

The value output from these two pins is mapped to 256 i.e. o to 255. The value from each color determine the color it detects. Now it’s time to set the frequency. Input pin S0 and S1 do this job. By using these two pins we can set the frequency to 0%, 2%, 20% and 100%. Let’s see the truth table of for frequency selection switch.

For the project Arduino Color Sensor Project, the frequency is set to 20%, this can be done in software code. You have to assign HIGH for S0 pin and LOW for S1.

block diagram of arduino color sensor projects

Circuit Description of Arduino Color Sensor Project

The circuit is shown in figure 2. build around Arduino uno board, TCS230 Color sensor and 16×2 LCD. VCC pin of TCS230 is connected to +5V arduino supply where GND and OE pin is connected to ground. Frequency selection pin S0 and S1 is connected to arduino uno digital pin D2 and D3. Color Pin S2 and S3 is connected to arduino pin DD4 and D5 where the output pin (OUT) is connected to arduino D6.

circuit diagram of arduino color sensor projects

LCD is connected in 4-bit higher order data bit i.e. only higher data pin D4 to D7 of LCD is used to communicate with LCD. Four higher order data bit D4, D5, D6 and D7 is connected to arduino D10, D9, D8 and D7 respectively where RS and E pin is connected to D12 and D11 pin of arduino as shown in circuit diagram. VSS, RW and LED- pin is connected to GND, where VDD pin is connected to +5V power supply. VEE pin must be at lower potential than VDD but higher than VSS and this pin is responsible for contrast control.

If you are new to arduino and LCD interface then please do watch this video on “Interfacing of 16×2 LCD with Arduino”.

Software code: Software code for this project is written in arduino programming language and compiled using arduino IDE.

Procedure of Arduino Color Sensor Projects

  • Copy the above code in your arduino IDE, upload it in your Arduino board.
  • Open serial monitor and place any color object in from of color senor TCS230.

serial monitor output of TCS230

  • There you will see different value of R, G, B.
  • At first, place the colored object near the color sensor and note down the value of R, B and  G shown in serial monitor.
  • Similarly, place the colored object far from the color sensor and note down the value of R, B and G shown in serial monitor.

value of color when you place near and far from sensor

  • Follow the same procedure of previous step for different color.
  • Now update the code with the value you have measured.
  • Scroll down to color frequency comparing code and there update the previous value of R, B and G with the value you have measured.

max and min value

Note: The value of R, B and G is different at different intensity of light i.e. it show different value of R, B and G for same color at dark and at light. The value of R, B and G might be different then the value used in code so please measure the color for specified object with your own color sensor.

Leave a Comment