• Home
  • Prakash
    • R and D
    • Smart Home
  • Basics
    • Capacitors
      • Color codeing Disc Capacitor Capacitor characterstics Polarity Non Polarity Series Connection Parallel Connection
    • Diodes
      • Zener Diode Light Emitting Diode Signal Diode Photo Diode
    • Inductors
    • Transistor
      • Silicon Germenium NPN PNP MOSFET SCR
    • Resistors
      • Color codeing 4-Band 5-Band Series Parallel Potential Meter
    • Logics
      • Analog Logic
      • Digital Logic
      • Hexa Decimal Numbers
      • Octal Numbers
      • Binary Fraction
      • Binay to Decimal
    • OP-Amplifiers
      • Basics
      • Oscillators
      • Transistor Switch
      • 555 IC circuits
      • Waveform Generators
      • 741 IC Circuits
    • Power supply
      • Transformer
      • Halfwave Rectifier
      • Fullwave Rectifier
      • Bridge Rectifier
      • 78xx Series
      • 0 to 30v Regulator
  • Modules
    • H-Bridge
      • L293D Bridge
      • Relay Bridge
    • RF 434MHz Modules
    • Relay Modules
    • Push to ON switch
    • Push to OFF switch
  • Sensors
    • Analog sensors List-1
      • LDR Photo Diode Solar Cell Transducers Temperature Humidity Sensor Soil Moisture Ranger Sensor Range Detection
    • Analog sensors List-2
      • Flame Sensor Force Sensor Flex Sensor Ambient Sensor Motion Sensor Vibration Sensor Sound Sensor UltraSonic Sensor GrayScale Sensor
    • Digital Sensors
      • Touch Sensor Tilt Sensor Signal
    • 3-Axis Sensor
    • Gyro Sensor
  • Projects
    • Embedded
      • Mini Projects 8051 Arduino NodeMCU MSP430 Raspberry IOT ARM
    • C #
      • Visual Basic Visual Studio
    • Matlab
    • VLSI
    • PHP-HTML
    • Contribute
  • Downloads
  • Technology

Arduino Based Color Detector


A Color Sensor, as the name suggests, is a device that senses or detects colors. A color sensor will use an external means of emitting light (like an array of white LEDs) and then analyse the reflected light from the object in order to determine its color.
Color sensors will give an accurate color of the object. There are a wide range of applications of color sensors like sorting objects by color, quality control systems, printer color enhancement etc.
In this project, we have designed a simple Arduino Color Sensor application, which has an ability to detect different colors. We have used TCS3200 color sensors for this purpose. Introduction to color sensor, circuit diagram and working of the Arduino Color Sensor project are explained below.
Arduino Color Sensor Images 1 Arduino Color Sensor Images 2
Arduino Color Sensor Images 3 Arduino Color Sensor Images 4 
                                       Arduino Color Sensor Images 5


Components Required

  • Arduino Mega
  • TCS3200 (RGB + Clear) Color Sensor Module
  • Breadboard (Prototyping board)
  • Power supply
  • Connecting wires
NOTE: We have used Arduino Mega in this project as it has large number of I/O pins and we have connected many devices like TCS 3200 Color Sensor, 16X2 LCD Display and 4 LEDS. For simple Sensor Data using Serial Communication (Sensor information on the Serial Terminal), simple Arduino UNO can be used.

A Brief Introduction to Color Sensor

Technically speaking, colors are figments of our imagination. When we see a red apple, it means that it reflects that particular wavelength (~700 nm for Red) of the electromagnetic spectrum. This energy is absorbed by the eye and based on some chemical reaction, the brain says that particular wavelength is red color.
For computers, a sensors that differentiates between different colors will help in determining the color of the object. We will see a simple color sensor using a photo resistor (Light Dependent Resistor – LDR) and two different colored objects, say red and blue.

When we shine bright red light on both the objects, the red object will reflect the light whereas the blue object will absorb it. So, when red light is incident on both the red and blue objects, the red objects appears brightest to the LDR as it reflects most of the red light.


LDR Blue



Similarly, when a bright blue light is incident on both the objects, the blue object will appear the brightest to the sensor. This method is just to understand the working of a color sensor and the actual results may not be accurate.



LDR Red

Practical Color Sensors like TCS3200 are a bit more complicated than this. The TCS3200 color sensor is a programmable color sensor which converts color light to frequency. The output frequency of the sensor is directly proportional to the intensity of the light reflected from the object.
The TCS3200 Color Sensor Module has RGB + Clear Sensor along with 4 bright white LEDs embedded on the board. TCS3200 has an 8 x 8 array of photo diodes, 16 each for Red filters, Blue filters, Green filters and Clear (no filter).
The functional block diagram of TCS3200 Color Sensor is shown in the following image. It consists of color filters, photo diode array, current to frequency converter and final square wave output which can be given directly to a microcontroller.
Color Sensor Block Diagram

The TSC3200 Color Sensor IC is an 8 pin IC with SOC package. The following image shows the pin diagram of the Color Sensor IC. In that Pins 1 and 2 (S0 and S1) are output frequency scaling pins. Pin 3 is Output enable pin and is an active low pin. Pin 4 is GND
TCS3200 Pin Diagram

Pin 5 is the VDD pin and the maximum supply voltage is 5.5 V. Pin 6 is the output pin through which we can get the square wave output. Pins 7 and 8 (S2 and S3) are Photodiode selection pins.
Pins 1, 2 (S0, S1) and 7, 8 (S3, S4) are of special interest in TCS3200 Color Sensor. S0 and S1 are output frequency scaling pins. With these pins, the frequency of the output square wave can be scaled according to the application or microcontroller used.
The reason for scaling of output frequency is different microcontrollers have different timer configurations and there might be some limitations in the counter functionality of the microcontrollers. The following table shows the percentage of output scaling for different combinations of S0 and S1

S0S1Output Frequency Scaling (f0)Typical full-scale Frequency
LLPower Down———-
LH2%10 – 12 KHz
HL20%100 – 120 KHz
HH100%500 – 600 KHz
S3 and S4 are photo diode selection pins. They are used to select different photo diodes which are associated with different color filters (Red, Blue, Green and Clear). The following table shows different combinations of S3 and S4 for different types of photo diodes.
S3 and S4 are photo diode selection pins. They are used to select different photo diodes which are associated with different color filters (Red, Blue, Green and Clear). The following table shows different combinations of S3 and S4 for different types of photo diodes


S3S4Photodiode Type
LLRed
LHBlue
HLClear (no filter)
HHGreen

The TCS 3200 Color Sensor comes in the form of a Module with all the components like header pins, 4 White LEDs, Resistors and Capacitors in addition to the Actual TCS 3200 Color Sensor. The following image shows the real time Color Sensor Module.
TCS3200 Color Sensor


Working of the Project

A simple Color Sensor using Arduino is developed in this project. The color sensor module senses the color in its surroundings. The working of the project is explained here.
As mentioned in the introduction to color sensor section, the TCS3200 Color Sensor has filters for Red, Blue, Green and Clear. The intensity of each color is represented as a frequency. In Arduino, we have fixed the output frequency scale to 100% by applying HIGH to S0 and S1 pins of the color sensor.
We have to use the S2 and S3 pin on the color sensor to select the type of photo diode i.e. red, green or blue. Whenever a particular Photo diode is selected, the PULSEIN feature of the Arduino is activated on the pin that is connected to the output of the Color Sensor.
This will help us to calculate the frequency of the output signal. The same process is repeated for all the three photo diodes: R, G and B. The frequency in all the cases is measured using the PULSEIN feature and is displayed on the Serial Terminal.
Additionally, this information can be used to identify the color placed in front of the sensor and display its color on the LCD and also light up the corresponding LED. 

CODE 

/*Arduino Mega*/
#include<LiquidCrystal.h>
LiquidCrystal lcd(42,43,44,46,48,50);
const int S0 = 7;
const int S1 = 6;
const int outPut= 5;
const int S2 = 4;
const int S3 = 3;
unsigned int frequency = 0;
void setup()
{
Serial.begin(9600);
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(OutPut, INPUT);
digitalWrite(S0,HIGH);
digitalWrite(S1,HIGH);
}
void loop()
{
Serial.print("R=");
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
frequency = pulseIn(outPut, LOW);
Serial.print(frequency);
Serial.print("\t");
delay(500);
Serial.print("B=");
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
frequency = pulseIn(outPut, LOW);
Serial.print(frequency);
Serial.print("\t");
delay(500);
Serial.print("G=");
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
frequency = pulseIn(outPut, LOW);
Serial.print(frequency);
Serial.print("\t");
delay(500);
Serial.print("\n");
}

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Related Posts:

  • HOW TO POST DATA TO GOOGLE SHEETS USING ESP8266 In the past couple years, the ESP8266 platform has flourished dramatically and emerged as one of the most popular hardware tools among electronics h… Read More
  • MY TEST CODE int sensor1=2; int sensor2=3; int sensor3=4; int x; int y; int z; int state; int flag=0; int led1 =5; int led2 =6; int led3 =7; int reset = 8; int bu… Read More
  • Sound Card ECG With AD8232 Every few years I revisit the idea of building an ECG machine. This time I was very impressed with how easy it is to achieve using the … Read More
  • Downloads Embedded  Keil 4  Code Composer Studio c6713 Hyperterminal MSP 430 Software Arduino Arduino 1.8.5(non admin install) … Read More
  • ECG MONITORING SYSTEM AD8232 Heart Rate Monitor Hookup Guide Share on TwitterShare on FacebookPin It Introduction The AD8232 is a neat little chip use… Read More
Terms and Conditions -
Privacy Policy -

Contact Us

Name

Email *

Message *