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.

  • 230 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

  • 1,664 views
  • 0 comments
  • 1 respect

GSM based Home Automation

Project tutorial by Team Brink.IO

  • 18,835 views
  • 45 comments
  • 40 respects

Control your LED with Cortana

Project tutorial by Mohamed Emam

  • 8,723 views
  • 7 comments
  • 21 respects

Arduino-Based Automatic Water Tap Using IR Sensor

Project tutorial by Team Creatjet3D R&D Team

  • 5,652 views
  • 6 comments
  • 19 respects

Control the Speed of Brushless DC Motor Using Bluetooth

Project tutorial by mohitmehlawat

  • 3,497 views
  • 0 comments
  • 13 respects

Interactive LED Name

Project tutorial by Pedro Mendez and Daniel Jablonski

  • 1,893 views
  • 1 comment
  • 5 respects
Add projectSign up / Login