Project tutorial
Arduino Based Color Detector TCS3200 Using LED & Breadboard

Arduino Based Color Detector TCS3200 Using LED & Breadboard © GPL3+

How to make a color sensing device using a TCS3200 color sensor.

  • 3,033 views
  • 0 comments
  • 2 respects

Components and supplies

About this project

Code

Arduino based colour detector tcs3200 using led and breadboardC/C++
Arduino based colour detector tcs3200 using led and breadboard.In this Arduino based color detector video tutorial, you can learn how to make color sensing device with TCS-3200/230 color sensor and detect different colors objects using this color sensor.There are wide range of applications of color sensor like sorting objects by colors quality control systems, Printer color enhancement etc.
// www.creatjet3d.com
#include <LiquidCrystal.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

// TCS230 pins connected to Arduino
const int s0 = 6;
const int s1 = 5;
const int s2 = 4;
const int s3 = 3;
const int out = 2;

// Variables
int red = 0;
int green = 0;
int blue = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);
  pinMode(out, INPUT);

  digitalWrite(s0, HIGH);
  digitalWrite(s1, HIGH);

  lcd.begin(16, 2);
  lcd.setCursor(5, 0);
  lcd.print("Arduino");
  lcd.setCursor(1, 1);
  lcd.print("Color Detector");
}

void loop()
{
  color();
  Serial.print("R =");
  Serial.print(red, DEC);
  Serial.print(" G = ");
  Serial.print(green, DEC);
  Serial.print(" B = ");
  Serial.print(blue, DEC);
  Serial.print("\t");

  if (red < blue && red < green && red < 25)
  {
    if (green - blue >= 10 && green - blue <= 25 && green - ( 2 * red ) >= 8 )
    {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Color Detection");
      lcd.setCursor(0, 1);
      lcd.print("Color : ");
      lcd.print("Red");
      Serial.println(" - (Red Color)");
    }

   else if (green - red <= 10 && green - red >= -3 && blue >= green)
    {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Color Detection");
      lcd.setCursor(0, 1);
      lcd.print("Color : ");
      lcd.print("Yellow");
      Serial.println(" - (Yellow Color)");
    }
    
    else if (blue - red >= 3 && blue - red <= 10 &&  green - ( 2 * red ) <= 5)
    {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Color Detection");
      lcd.setCursor(0, 1);
      lcd.print("Color : ");
      lcd.print("Pink");
      Serial.println(" - (Pink Color)");
    }
    
    else if (green - blue >= -5 && green - blue <= 5 && green - ( 2 * red ) <= 5 )
    {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Color Detection");
      lcd.setCursor(0, 1);
      lcd.print("Color : ");
      lcd.print("Orange");
      Serial.println(" - (Orange Color)");
    }

  }

  else if (green < red && green < blue && green < 25)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Color Detection");
    lcd.setCursor(0, 1);
    lcd.print("Color : ");
    lcd.print("Green");
    Serial.println(" - (Green Color)");
  }

  else if ((red > green &&  blue < green) && blue < 25 && red > 40)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Color Detection");
    lcd.setCursor(0, 1);
    lcd.print("Color : ");
    lcd.print("Blue");
    Serial.println(" - (Blue Color)");
  }

  else if (red - (2 * blue) >= -2 && red - (2 * blue) <= 5 && green - red < 10)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Color Detection");
    lcd.setCursor(0, 1);
    lcd.print("Color : ");
    lcd.print("Purple");
    Serial.println(" - (Purple Color)");
  }
  else if (blue < red && blue < green && (blue && red && green) < 25)
  {

    if (red - green <= 5 && red - green >= 0 && ((green - blue) || (red - blue)) < 5 && blue < 50)
    {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Color Detection");
      lcd.setCursor(0, 1);
      lcd.print("Color : ");
      lcd.print("White");
      Serial.println(" - (White Color)");
    }
  }

  Serial.println();

  delay(300);
}

void color()
{
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  //count OUT, pRed, RED
  red = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
  digitalWrite(s3, HIGH);
  //count OUT, pBLUE, BLUE
  blue = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
  digitalWrite(s2, HIGH);
  //count OUT, pGreen, GREEN
  green = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
}

Schematics

Arduino based colour detector tcs3200 using led and breadboard
In this Arduino based color detector video tutorial, you can learn how to make color sensing device with TCS-3200/230 color sensor and detect different colors objects using this color sensor.There are wide range of applications of color sensor like sorting objects by colors quality control systems, Printer color enhancement etc.
Colour sensor circuit diagram oyl0zb61ao

Comments

Similar projects you might like

Controlling an RGB LED with Color Detector Camera

Project tutorial by Zowail

  • 4,269 views
  • 0 comments
  • 2 respects

LED Color Sequencer

Project tutorial by Team thefantasticode.Group

  • 14,842 views
  • 17 comments
  • 40 respects

Color Sensor Prototype: Detect Color Name from Objects

Project tutorial by moretticb

  • 12,809 views
  • 7 comments
  • 35 respects

Plexiglass LED Table Lamp

Project tutorial by smellai and smellai

  • 2,077 views
  • 1 comment
  • 5 respects

RFID Based Automatic Door System

Project showcase by Robodia Technology

  • 77,367 views
  • 32 comments
  • 164 respects

GSM based Home Automation

Project tutorial by Brink.IO

  • 47,268 views
  • 56 comments
  • 81 respects
Add projectSign up / Login