Color Sensor-TCS230 with Arduino Uno

The TCS230 sensor 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. The TCS3200 color sensor can detect a wide variety of colors based on their wavelength. This sensor is especially useful for color recognition projects such as color matching, color sorting, test strip reading.

SENSOR PIN Description
GND=4 Power ground
OE=3 Enable for Output Frequency (Active Low)
OUT=6 Output Frequency
S0,S1=1,2 Output Frequency scaling selection inputs
S2,S3 = 7,8 Photo diode type selection inputs
VCC-5 Voltage supply

How does the TCS3200 sensor work?
The full-scale output frequency can be scaled by one of three preset values via two control input pins. Digital inputs and digital output allow direct interface to a micro-controller or other logic circuitry. Output enable (OE) places the output in the high-impedance state for multiple-unit sharing of a micro-controller input line.
In the TCS3200, the light-to-frequency converter reads an 8 x 8 array of photo-diodes. Sixteen photo-diodes have blue filters, 16 photodiodes have green filters, 16 photo-diodes have red filters, and 16 photo-diodes are clear with no filters.
In the TCS3210, the light-to-frequency converter reads a 4 x 6 array of photo-diodes. Six photo-diodes have blue filters, 6 photo-diodes have green filters, 6 photo-diodes have red filters, and 6 photo-diodes are clear with no filters.
The four types (colors) of photo-diodes are inter digitated to minimize the effect of non-uniformity of incident irradiance. All photo-diodes of the same color are connected in parallel. Pins S2 and S3 are used to select which group of photo-diodes (red, green, blue, clear) are active. Photo-diodes are 110 μm x 110 μm in size and are on
134-μm centers.
The TCS320 has an array of photodiodes with 4 different filters. A photodiode is simply a semiconductor device that converts light into current.

ALL SENSOR DETAILS:
1. HC-05 – Bluetooth
2. Mpu 6050 accelerometer-gyroscope- -module
3. Flame-sensor
4. Rotary-encoder
5. Force-sensor-fsr400
6. Current-sensor-acs712
7. Flex-sensor
8. IR-sensor-tcrt5000
9. Pulse-sensor-pin
10. Color-sensor-tcs230
11. SD-card-module
12. Oled-with-arduino
13. Addressable-rgb-led-strip-ws1812
14. Relay-module
15. TFT-1-8-display-st7735r
16. 8×8-dot-matrix-display-max7219
17. Smoke-sensor-mq-2
18. Ultrasonic-sensor-HC-sr04
19. PIR-motion-sensor-hc-sr501
20. Tilt-sensor-sw-520d
21. Microphone-sound-sensor
22. Reed-switch-reed-sensor
23. Rfid-reader-Em18
24. Rfid-tag
25. RTC-real-time-clock-ds1307
26. Temperature-sensor-ds18b20
27. Moisture-sensor
28. Rain-sensor
29. Pressure-sensor
30. Accelerometer
31. MOC-3021-circuit
32. DHT11-DHT22-temperature-and-humidity-sensor
1. 16 photo-diodes with red filter – sensitive to red wavelength
2. 16 photo-diodes with green filter – sensitive to green wavelength
3. 16 photo-diodes with blue filter – sensitive to blue wavelength
4. 16 photodiodes without filter
By selectively choosing the photodiode filter’s readings, you’re able to detect the intensity of the different colors. The sensor has a current-to-frequency converter that converts the photodiodes’ readings into a square wave with a frequency that is proportional to the light intensity of the chosen color. This frequency is then, read by the Arduino.
SPECIFICATIONS:
1. Single-Supply Operation (2.7 V to 5.5 V)
2. High-Resolution Conversion of Light Intensity to Frequency
3. Programmable Color and Full-Scale Output Frequency
4. Power Down Feature
5. Communicates Directly to Micro controller
6. S0~S1: Output frequency scaling selection inputs
7. S2~S3: Photodiode type selection inputs
8. OUT Pin: Output frequency
9. OE Pin: Output frequency enable pin (active low), can be impending when using
10. Support LED lamp light supplement control
11. Size: 28.4 x 28.4 mm
FEATURES:
A. Quality tested
B. Accurate functioning
C. Long service life
HOW TO USE WITH ARDUINO UNO CIRCUIT DIAGRAM:
COLOUR SENSOR WITH ARDUINO UNO CODE:
Copy and paste or download below given link
//Circuito.io is an automatic generator of schematics and code for off
//Copyright (C) 2016 Roboplan Technologies Ltd.
// Include Libraries
#include “Arduino.h”
#include “LED.h”
#include “Switchable.h”
// Pin Definitions
#define LEDB_PIN_VIN 5
#define LEDG_PIN_VIN 6
#define LEDR_PIN_VIN 9
#define TCS230_PIN_S1 4
#define TCS230_PIN_S0 3
#define TCS230_PIN_S3 8
#define TCS230_PIN_S2 7
#define TCS230_PIN_OUT 2
// Global variables and defines
// object initialization
LED ledB(LEDB_PIN_VIN);
LED ledG(LEDG_PIN_VIN);
LED ledR(LEDR_PIN_VIN);
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println(“start”);
menuOption = menu();
}

// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{
if(menuOption == ‘1’) {
// LED – Basic Blue 5mm – Test Code
// The LED will turn on and fade till it is off
for(int i=255 ; i> 0 ; i -= 5)
{
ledB.dim(i); // 1. Dim Led
delay(15); // 2. waits 5 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
}
ledB.off(); // 3. turns off
}
else if(menuOption == ‘2’) {
// LED – Basic Green 5mm – Test Code
// The LED will turn on and fade till it is off
for(int i=255 ; i> 0 ; i -= 5)
{
ledG.dim(i); // 1. Dim Led
delay(15); // 2. waits 5 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
}
ledG.off(); // 3. turns off
}
else if(menuOption == ‘3’)
{
// LED – Basic Red 5mm – Test Code
// The LED will turn on and fade till it is off
for(int i=255 ; i> 0 ; i -= 5)
{
ledR.dim(i); // 1. Dim Led
delay(15); // 2. waits 5 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
}
ledR.off(); // 3. turns off
}
else if(menuOption == ‘4’) {}
// Disclaimer: The TCS230 Color RGB Sensor is in testing and/or doesn’t have code, therefore it may be buggy. Please be kind and report any bugs you may find.
if (millis() – time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F(“\nWhich component would you like to test?”));
Serial.println(F(“(1) LED – Basic Blue 5mm”));
Serial.println(F(“(2) LED – Basic Green 5mm”));
Serial.println(F(“(3) LED – Basic Red 5mm”));
Serial.println(F(“(4) TCS230 Color RGB Sensor”));
Serial.println(F(“(menu) send anything else or press on board reset button\n”));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == ‘1’)
Serial.println(F(“Now Testing LED – Basic Blue 5mm”));
else if(c == ‘2’)
Serial.println(F(“Now Testing LED – Basic Green 5mm”));
else if(c == ‘3’)
Serial.println(F(“Now Testing LED – Basic Red 5mm”));
else if(c == ‘4’)
{
Serial.println(F(“Now Testing TCS230 Color RGB Sensor – note that this component doesn’t have a test code”));
else
{
Serial.println(F(“illegal input!”));
return 0;
}
time0 = millis();
return c;
}
}
}
Download the full Arduino Uno code here.colour sensor with led

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 505

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×