TCS3200 Color Sensor Arduino and LCD display circuit

TCS3200 Color Sensor Arduino and LCD display circuit

TCS3200 Color Sensor Arduino and LCD display circuit. fritizing diagram
TCS3200 Color Sensor Arduino and LCD display circuit diagram

TCS3200 Color Sensor Arduino and LCD display circuit

In this article we will learn how to Interface Arduino with TCS3200 color sensor and LCD display.
In the last post we will learn how to Interface Arduino with water level indicator using sonar sensor and LEDs in proteus. You can visit our website,
I hope you appreciate my work, let’s discuss about today’s project.

 

 

 

Components:

  1. Arduino UNO
  2. Battery 9V
  3. Resistor variable 10k
  4. LCD display
  5. Color Sensor
  6. Jumper wires

Construction…

  • Connect one side of battery with GND pin of Arduino
  • Connect 2nd side of battery with Vin pin of Arduino
  • Connect 5v pin of Arduino with +ve pin of variable then connect it with VDD pin of LCD display then connect it with VCC pin of Color senor through one side of resistor
  • Connect 2nd side of resistor with pin A of LCD display
  • Connect GND pin of Color sensor with K pin of LCD display
  • Connect K, RW, VSS pins of LCD display with GND pin of Arduino through –ve pin of variable
  • Connect signal pin of variable with VD pin of LCD display
  • Connect RS pin of LCD display with pin 2 of Arduino
  • Connect E pin of LCD display with pin 3 of Arduino
  • Connect D4 pin of LCD display with pin 4of Arduino
  • Connect D5 pin of LCD display with pin 5 of Arduino
  • Connect D6 pin of LCD display with pin 6 of Arduino
  • Connect D7 pin of LCD display with pin 7 of Arduino
  • Connect OUT pin of Color sensor with pin 8 of Arduino
  • Connect S0 pin of Color sensor with pin 9 of Arduino
  • Connect S1 pin of Color sensor with pin 10 of Arduino
  • Connect S2 pin of Color sensor with pin 11 of Arduino
  • Connect S3 pin of Color sensor with pin 12 of Arduino

Working…

The TCS3200 color sensor is a popular sensor for detecting and measuring colors. It works by illuminating an object with white light and then analyzing the reflected light to determine the color of the object. When combined with an Arduino and an LCD display, you can create color detection and display system.

Applications…

  1. Color Sorting Machine
  2. Color Mixing and Art
  3. Paint Mixing
  4. Food Quality Testing
  5. Educational Tools

Advantages…

  1. Precise Color Detection
  2. Versatility
  3. Integration with Arduino
  4. LCD Display
  5. Real-time Feedback

Program code images…

TCS3200 Color Sensor Arduino and LCD display circuit,
TCS3200 Color Sensor Arduino and LCD program code.
TCS3200 Color Sensor Arduino and LCD display circuit diagram
TCS3200 Color Sensor Arduino and LCD program code.
TCS3200 Color Sensor Arduino and LCD display circuit diagram
TCS3200 Color Sensor Arduino and LCD program code.
TCS3200 Color Sensor Arduino and LCD display circuit diagram
TCS3200 Color Sensor Arduino and LCD program code.
TCS3200 Color Sensor Arduino and LCD display circuit diagram
TCS3200 Color Sensor Arduino and LCD program code.
TCS3200 Color Sensor Arduino and LCD display circuit diagram
TCS3200 Color Sensor Arduino and LCD program code.
TCS3200 Color Sensor Arduino and LCD display circuit diagram
TCS3200 Color Sensor Arduino and LCD program code.
TCS3200 Color Sensor Arduino and LCD display circuit diagram
TCS3200 Color Sensor Arduino and LCD program code.

 

Program code…

[dt_code]

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

 

LiquidCrystal_I2C lcd(0x27, 16, 2); // Replace 0x27 with your LCD address

 

#define outPin 8

#define s0 9

#define s1 10

#define s2 11

#define s3 12

 

boolean DEBUG = true;

 

// Variables

int red, grn, blu;

String color = “”;

long startTiming = 0;

long elapsedTime = 0;

 

void setup() {

Serial.begin(9600);

 

Wire.begin();  // Initialize the I2C communication

lcd.init();    // Initialize the LCD

lcd.backlight(); // Turn on the backlight

 

pinMode(s0, OUTPUT);

pinMode(s1, OUTPUT);

pinMode(s2, OUTPUT);

pinMode(s3, OUTPUT);

pinMode(outPin, INPUT); //out from sensor becomes input to Arduino

 

// Setting frequency scaling to 100%

digitalWrite(s0, HIGH);

digitalWrite(s1, HIGH);

 

lcd.clear();

lcd.setCursor(3, 0);

lcd.print(“Welcome To”);

lcd.setCursor(1, 1);

lcd.print(“Color Detector”);

delay(2000);

lcd.clear();

startTiming = millis();

}

 

void loop() {

getColor();

 

if (DEBUG) printData();

elapsedTime = millis() – startTiming;

if (elapsedTime > 1000) {

showDataLCD();

startTiming = millis();

}

}

 

/* read RGB components */

void readRGB() {

red = 0, grn = 0, blu = 0;

 

int n = 10;

for (int i = 0; i < n; ++i) {

// read red component

digitalWrite(s2, LOW);

digitalWrite(s3, LOW);

red = red + pulseIn(outPin, LOW);

 

// read green component

digitalWrite(s2, HIGH);

digitalWrite(s3, HIGH);

grn = grn + pulseIn(outPin, LOW);

 

// let’s read blue component

digitalWrite(s2, LOW);

digitalWrite(s3, HIGH);

blu = blu + pulseIn(outPin, LOW);

}

red = red / n;

grn = grn / n;

blu = blu / n;

}

 

/***************************************************

* Showing captured data at Serial Monitor

****************************************************/

void printData(void) {

Serial.print(“red= “);

Serial.print(red);

Serial.print(”   green= “);

Serial.print(grn);

Serial.print(”   blue= “);

Serial.print(blu);

Serial.print(” – “);

Serial.print(color);

Serial.println(” detected!”);

}

 

/***************************************************

* Showing captured data on LCD

****************************************************/

void showDataLCD(void) {

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(“R”);

lcd.print(red);

lcd.setCursor(6, 0);

lcd.print(“G”);

lcd.print(grn);

lcd.setCursor(12, 0);

lcd.print(“B”);

lcd.print(blu);

 

lcd.setCursor(0, 1);

lcd.print(“Color: “);

lcd.print(color);

}

 

void getColor() {

readRGB();

 

if (red > 41 && red < 43 && grn > 77 && grn < 81 && blu > 61 && blu < 63) color = “RED”;

else if (red > 17 && red < 78 && grn > 11 && grn < 77 && blu > 12 && blu < 72) color = “GREEN”;

else if (red > 22 && red < 70 && grn > 11 && grn < 680 && blu > 6 && blu < 42) color = “BLUE”;

else if (red > 4 && red <  24 && grn > 6 && grn < 30 && blu > 9 && blu < 32) color = “YELLOW”;

else if (red > 5 && red < 8 && grn > 4 && grn < 8 && blu > 3 && blu < 7) color = “WHITE”;

else if (red > 28 && red < 74 && grn > 25 && grn < 85 && blu > 20 && blu < 42) color = “BLACK”;

else color = “NO_COLOR”;

}

[/dt_code]