Professional Documents
Culture Documents
TCS230 RGB Color Sensor Operation and Code: Ravi Pujar 21 March 2015
TCS230 RGB Color Sensor Operation and Code: Ravi Pujar 21 March 2015
ravi@valetron.com (mailto:ravi@valetron.com)
(/)
The TAOS TCS230 is the most widely used color sensor by hobbyists and embedded system
practitioners. TCS230 is a RGB color sensor which provides the intensity value of Red, Green
and Blue colors detected at its input lens. The output is available on a single pin in the form
of a square wave.
Here is the image and the block diagram of the TCS230 color sensor,
The first block that comes into picture is the Photodiode array. The photodiode array consists
of three sets of diodes each for sensing Red, Green and Blue color respectively. So, when you
are measuring the intensity of Red light you need to enable only the Red photodiode array
and disable the other two photo diode arrays.
The output enable pin is generic output enable pin which turns the square wave output
ON/OFF.
Detecting the color: The TCS230 color sensor is having only one output pin on which a 50%
duty cycle square wave is output continuously.
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
1/10
10/5/2019 TCS230 RGB color sensor operation and Code
First we need to make the OE pin low to enable the sensor output, and then make the S0 = 1,
(/)scaled squarewave output.
S1 = 0 to select a 20%
When we are measuring the color of any object in front of the sensor, we need to perform
the measurement in three steps,
1. Measure the Red color: To enable only the Red photo diode array by making S2=0, S3=0.
Wait for sometime and measure the time period of the square wave on the output
pin by enabling only Red photodiode array.
2. Measure the Blue color: To enable only the Blue photo diode array by making S2=0,
S3=1. Wait for sometime and measure the time period of the square wave on the output
pin by enabling only Blue photodiode array.
3. Measure the Green color: To enable only the Green photo diode array by making S2=1,
S3=1. Wait for sometime and measure the time period of the square wave on the output
pin by enabling only Green photodiode array.
After you get the values of the Red, Green and Blue components, you can get the name of the
color from any RGB color table. You can also measure the light intensity on the sensor by
disabling color filters. To measure the light iintensity disbale the color filters by making S2=1,
S3=0. Wait for sometime and measure the time period of the square wave on the output pin.
Here i have configured the PIC's timer module in capture mode where i measure the square
waves time period. The color sensors output is connected to the timers capture input pin. To
measure RED color, i enable only the Red color receptors and measure the count in the timer
registers after a delay which gives me the pulse width.
Here is the piece of code i wrote for PIC16F877A microcontroller. If you want i can share the
libraries code.
Download the code for TCS230 color sensor with PIC16F877A microcontroller
(/Colour%20sensor_PIC16F877A_CompleteProject.zip)
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
2/10
10/5/2019 TCS230 RGB color sensor operation and Code
Circuit diagram for interfacing TCS230 RGB color sensor with PIC16F877A
microcontroller :
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
3/10
10/5/2019 TCS230 RGB color sensor operation and Code
(/)
The output of the color sensor is connected to INT0 of 8051 microcontroller. The
microcontroller uses the timer module to measure the time period of the square wave
pulses. The objective of the code is to detect the color as RED,BLUE,GREEN and move a
stepper motor to a particular position.
Here is a piece of code i wrote for interfacing TCS230 color sensor with 89s52/8051
microcontroller.
Download the code for TCS230 color sensor with 89s52/8051 microcontroller
(/Colour%20sensor_8051_89S52_CompleteProject.zip)
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
4/10
10/5/2019 TCS230 RGB color sensor operation and Code
1;mot2 =0; mot3 =1; mot4 =1; Delay(500); mot1 =0;mot2 =1; mot3 =1; mot4 =1;
DisplayString(LINE4,"250 KG = ",BlueBags,DATA_WRITE);} void SendPacket(void){//GIE = 0; Print
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
△ ▽ • Reply • Share ›
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
6/10
10/5/2019 TCS230 RGB color sensor operation and Code
jp • 4 years ago
(/)
hello...i am using this colour snsor tcs230 in my projct bt it is unable to detect the colour of
cloths...is there any solution of this problm......
△ ▽ • Reply • Share ›
TATIANA • 6 years ago
PLEASE, YOU GIVE ME LIBRARIES CODE. I NEED IT FOR MY PROJECT. THX
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor 7/10
10/5/2019 TCS230 RGB color sensor operation and Code
△ ▽ • Reply • Share ›
(/)
ChuDaiHai > TATIANA • 6 years ago
Please, you give me principle diagram of TCS230 conect with PIC16F877A. I need it for
my Project. Thank much!
△ ▽ • Reply • Share ›
TCS230 with 8051/89S52 including code for 20x4 line LCD, stepper motor
Regards,
Ravi
△ ▽ • Reply • Share ›
Google Speech Recognition HTTP API - How to order components from Digikey to
Tutorial with Live Demo .. ! India without Shipping charges
2 comments • a year ago 1 comment • 2 years ago
Tech Seeker — Thanks for the post. I am trying Achiever — Hey, the above mentioned mail-id's
Avatarto get Google speech to text work and am Avatarno more work.... Their new E-mail is
stuck.I appear to form the JSON correctly.Only pallavi@sourcetechnologi.com
Difference between SIM900 and SIM900A Arduino MQTT Library with Publish and
GSM modems Subscribe example
1 comment • 2 years ago 3 comments • a year ago
anbu — hi , I'm not able to send text sms and Najab Haider —
Avatarmaking call upto 10 numbers , i'm using AvatarSoftSerial.print("AT+CIPMODE=0\r\n");Respons
back to top
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
8/10
10/5/2019 TCS230 RGB color sensor operation and Code
Facebook (http://www.facebook.com/sharer.php?u=https://www.raviyp.com/embedded/135-
(/) taos-tcs230-color-sensor)
Twitter (http://twitter.com/share?url=https://www.raviyp.com/embedded/135-taos-tcs230-color-
sensor&text=TCS230%20RGB%20color%20sensor%20operation%20and%20Code)
(https://plus.google.com/share?url=https://www.raviyp.com/embedded/135-taos-tcs230-color-
sensor)
(http://www.linkedin.com/shareArticle?mini=true&url=https://www.raviyp.com/embedded/135-
taos-tcs230-color-sensor)
(https://plus.google.com/102969188306424582103)
Email:ravi@valetron.com
(mailto:ravi@valetron.com)
Find us on Google+
(https://plus.google.com/104907583360502363516)
HIRE ME FOR YOUR PROJECT AS A
FREELANCER
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
9/10
10/5/2019 TCS230 RGB color sensor operation and Code
Ravi Pujar
YouTube (/)
3k
Subscribe
Embedded World
7.1K likes
Like Page
Embedded World
about a week ago
https://www.raviyp.com/…/250-
don-t-buy-components-for-your-
…
https://www.raviyp.com/embedded/135-taos-tcs230-color-sensor
10/10