This is a simple color sensor using Arduino Uno R3 and TCS3200 color sensor module. It can be useful for color identification and detection for food-processing units, color printer applications, paint-mixing applications and other industrial applications including robotics.
This project is used for detecting primary colors (red, green and blue, or RGB)—colors that are physically available in LEDs in one package; for example, common cathode or common-cathode RGB LED. We can display primary colors and also generate specific colors by modifying the Arduino code. The project demonstrates the basic interfacing of TCS3200 sensor, Arduino Uno and common-cathode RGB LED.
TCS3200 color sensor module (SEN0101) is shown in Fig. 1 and microscopic view of the RGB arrays is shown in Fig. 2. On the microscopic level, you can see the square boxes inside the eye on the sensor. These square boxes are arrays of the RGB matrix. Each of these boxes contains three sensors: one each for sensing red light, green light and blue light intensity. It is better than TCS230 color sensor module. This sensor can be used to identify any number of colors with an accurate programming code.
Circuit and working
Fig. 3 shows the circuit diagram of the RGB color detector using TCS3200. It works off 9V power supply connected across connector CON1. However, an Arduino Uno board requires only 5V. So it has a bridge rectifier with a regulator that converts 9V to 5V logic, which can further be converted to 3.3V with the help of LM1117 voltage regulator.
Brain of the circuit is Arduino Uno R3 board having ATmega328 or ATmega328P microcontroller (MCU). It has 14 digital input/output (I/O) pins and six analogue input pins, 32k flash memory, 16MHz crystal oscillator, USB connection, power jack, ICSP header and reset button.
TCS3200 module has eight pins as shown in Fig. 4. This module consists of programmable color light-to-frequency converters that combine configurable silicon photodiodes and current-to-frequency converter on a single monolithic CMOS integrated circuit. Output is square-wave (50 per cent duty cycle) with frequency directly proportional to light intensity (irradiance).
Digital inputs and outputs allow direct interface to the MCU or other logic circuitry. Output enable (OE) places the output in high-impedance state for multiple units sharing an MCU input line. In TCS3200, the light-to-frequency converter reads an 8×8 array of photodiodes. Sixteen photodiodes have blue filters, another sixteen have green, yet another sixteen have red and remaining sixteen are clear with no filters.
All photodiodes of the same color are connected in parallel. Pins S2 and S3 of TCS3200 are used to select the group of photodiodes (red, green, blue and clear) that are active. The detailed pin description is shown in Tables I, II and III, respectively.
Each sensor array in these three arrays is selected separately, depending on the requirement. Hence, it is known as a programmable sensor.
The module can be used to sense a particular color only. It contains filters for selection purpose. There is a fourth mode with no filter. With no filter, the sensor detects white light.
Construction and testing
A single-side PCB layout of the RGB color detector using TCS3200 is shown in Fig. 5 and its component layout in Fig. 6.
Download PCB and component layout PDFs: click here
Working of the project is simple because this is a basic circuit for interfacing a TCS3200 sensor. When red color is kept near the sensor, it automatically detects the color with the help of photodiode arrays and then RGB color intensity value is displayed in Arduino serial monitor window along with color name. At the same time, a red LED glows in the RGB LED. Similarly, the remaining two colors (green and blue) are shown in Arduino serial monitor window and the respective color LED glows in RGB LED.
Software is written in Arduino programming language. Arduino Uno Board1 is programmed using Arduino IDE software. ATmega328P on Arduino Uno board comes with a pre-programmed bootloader that allows you to upload new code to it without using an external hardware programmer.
Connect Arduino board to the PC and select the correct COM port in Arduino IDE. Compile the program/sketch (TCS3200.ino). Select the correct board from Tools→Board menu in Arduino IDE and upload the sketch.
Load the program to the internal memory of the MCU. The sketch is at the heart of the system and carries out all major functions. It is compiled and uploaded using Arduino IDE 1.6.4.
Download source code
In this project, external header files are not required for programming. It is a simple way to detect RGB color intensities on the serial port. The author’s prototype is shown in Fig. 7.
Parmarthi Kanakaraja is assistant professor in Usha Rama College of Engineering and Technology, Andhra Pradesh.