Arduino Color Detection Project Using Adafruit TCS34725 RGB Color Sensor

 

 Arduino Color Detection System using Adafruit TCS34725 RGB Color Sensor

Build a high-accuracy Arduino color detection system using the powerful TCS34725 RGB Color Sensor and display real-time RGB values on both LCD and OLED screens. This project is ideal for automation, smart quality inspection, robotics, and industrial color sorting applications.

Powered by the reliable Arduino Uno, the system uses I2C communication to capture precise red, green, blue, and ambient (clear) light values with excellent stability under different lighting conditions.


 Arduino Color Detection Project Overview

This Arduino-based color recognition system reads raw 16-bit RGB data from the sensor, processes it, identifies dominant colors, and displays:

  • Detected color name (RED, GREEN, BLUE, etc.)

  • Real-time RGB intensity values

  • Graphical RGB bar visualization on OLED

  • Serial monitor debug data

The built-in IR blocking filter of the TCS34725 ensures improved color accuracy by reducing infrared interference — making it far superior to basic RGB modules.


 Key Features of This Arduino Color Sensor Project

✅ High-precision RGB color detection
✅ 16-bit color resolution
✅ Ambient light (Clear channel) measurement
✅ I2C communication (minimal wiring)
✅ Adjustable gain & integration time
✅ Compatible with 3.3V and 5V systems
✅ Real-time LCD display output
✅ OLED graphical RGB bars
✅ Onboard LED illumination for stable readings


 Components Used

  • Arduino Uno

  • Adafruit TCS34725 RGB Color Sensor

  • 16x2 I2C LCD Display

  • SSD1306 OLED Display

  • Jumper wires

  • Breadboard


How the Arduino Color Detection System Works

1️⃣ Color Sensing

The TCS34725 captures:

  • Red value

  • Green value

  • Blue value

  • Clear (ambient light)

2️⃣ Data Processing

The Arduino:

  • Reads raw 16-bit RGB values

  • Maps values into a usable range

  • Compares dominant RGB components

  • Determines detected color

3️⃣ Display Output

  • LCD shows detected color name

  • OLED displays graphical RGB bars

  • Serial Monitor prints detailed values


Color Identification Logic (From Your Code)

The system determines color based on dominant RGB values:

  • If R > G & R > B → RED

  • If G > R & G > B → GREEN

  • If B > R & B > G → BLUE

  • Equal combinations → Mixed colors

  • All equal → White / Neutral

This simple but effective logic works well for:

  • Object sorting

  • Packaging inspection

  • Smart automation


 OLED Visualization Feature

Your OLED implementation:

  • Draws real-time RGB bar graphs

  • Updates every 500 ms

  • Displays dynamic intensity changes

  • Creates a professional UI look

This makes the project ideal for demonstrations and industrial-style prototypes.


Applications of Arduino Color Detection System

 Industrial Automation

  • Smart color sorting machines

  • Packaging verification

  • Label color validation

 Food & Agriculture

  • Fruit ripeness detection

  • Vegetable grading

  • Food freshness monitoring

Robotics

  • Line-following robots with color detection

  • Object classification bots

  • Automated warehouse systems

 Education

  • STEM learning projects

  • Embedded systems labs

  • IoT prototype development


Why Use the TCS34725 Instead of Basic RGB Modules?

The Adafruit TCS34725 RGB Color Sensor offers:

✔ Integrated IR filter
✔ 16-bit precision
✔ Wide dynamic range
✔ Stable readings in ambient light
✔ Reliable I2C communication
✔ Adjustable sensitivity

Compared to low-cost RGB sensors, it provides significantly higher accuracy and stability for real-world automation.


Coding:
#include <Wire.h>
#include "Adafruit_TCS34725.h"
#include <LiquidCrystal_I2C.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define WIDTH 128
#define HEIGHT 64

LiquidCrystal_I2C lcd(0x27, 20, 4);
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
Adafruit_SSD1306 display(WIDTH, HEIGHT, &Wire, 1);

void setup(void) {
  Serial.begin(9600);
  if (tcs.begin()) {
    Serial.println("Found sensor");
  }
  else {
    Serial.println("No TCS34725 found ... check your connections");
    while (1);
  }

  lcd.init();
  lcd.clear();
  lcd.backlight();


  lcd.setCursor(0, 0);

 
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)){
     Serial.println("OLED not found");
   }

  Serial.println("OLED FIND");
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,28);
  display.println("hello");
  display.display();
 
 pinMode(A0, OUTPUT);
 digitalWrite(A0, HIGH);

}

void loop(void) {
 uint16_t red, green, blue, c;
 tcs.getRawData(&red, &green, &blue, &c); // 색상 감지 센서에서 측정 값 받아오기

// 색상 감지 센서에서 받아온 데이터 값을 사용 가능하게끔 수치 변경
int r =map(red,0,21504,0,1025);
int g =map(green,0,21504,0,1025);
int b =map(blue,0,21504,0,1025);

  Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
  Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
  Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
  Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
  Serial.println(" ");

  if(r > g && r > b){
   
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("RED");
   
  }
  else if(g > r && g > b){
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("GREEN");
     
  }
  else if(b > r && b > g){
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("BLUE");
     
  }
  else if( g == b && r == b){
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("ALL");
  }
  else if( g == b && g > r){
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("GREEN & BLUE");
  }
  else if(g == r && g > b){
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("GREEN & RED");
  }
  else if(r == b && r > g){
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("RED & BLUE");

  }
  else{
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("else");
  }

    display.clearDisplay();

  // Draw red bar
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("R:");
  display.fillRect(20, 0, r, 10, SSD1306_WHITE);

  // Draw green bar
  display.setCursor(0, 15);
  display.print("G:");
  display.fillRect(20, 15, g, 10, SSD1306_WHITE);

  // Draw blue bar
  display.setCursor(0, 30);
  display.print("B:");
  display.fillRect(20, 30, b, 10, SSD1306_WHITE);

  display.display();



  delay(500);
}

 

IOT & SMART SYSTEM PROJECTS

  1. IoT Weather Monitoring System (NodeMCU ESP8266 + DHT11 + Rain Sensor)
  2. ESP8266 NodeMCU Smart Health & Environment Monitoring System with Pulse, Temperature and Motion Sensors
  3. ESP32 Wi-Fi Weight Sensor with HX711
  4. Smart RFID Access Control System Using ESP32 Dev Board and UHF RFID Reader Module
  5. Smart IoT Motor Control System Using ESP32 Dev Board and L298N Motor Driver Module
  6. Smart Waste Management System Using Arduino Nano, Ultrasonic Sensor & GSM Module – Solar Powered IoT Solution
  7. Raspberry Pi Zero W and GSM SIM900 Based Ultrasonic Distance Measurement System
  8. Arduino UNO Smart Surveillance System with ESP8266 WiFi, PIR Motion Sensor & Camera Module
  9. Arduino UNO Environmental Monitoring System with OLED & 16x2 I2C LCD Display
  10. Arduino UNO-Based Smart Home Automation System with Flame and IR Sensors 
  11. Arduino Nano-Based Landslide Detection System with GSM Alerts – Smart Disaster Monitoring Project
  12. Arduino Nano Rain-Sensing Stepper Motor System
  13. Arduino Based Automatic Tire Inflator Using Pressure Sensor, Relay Module and LCD Display
  14. Arduino-Based Automatic Cooker Using Servo Motors, DC Stirrer Motor, Temperature Sensor and Relay-Controlled Heater
  15. Arduino Sketch for Plastic Bottle and Can Reverse Vending Machine

 TRAFFIC & SMART CITY PROJECTS
  1. RFID-Based Smart Traffic Control System (Arduino Mega)
  2. Arduino UNO Traffic Light Control System – Smart LED Signal Project
  3.  Arduino UNO Controlled Traffic Light System with Joystick Interface

ROBOTICS PROJECTS
  1. Arduino UNO Smart Obstacle Avoiding Robot (Ultrasonic + IR + GSM)
  2. Arduino-Powered Autonomous Obstacle Avoidance Robot with Servo Control
  3. Arduino Nano Bluetooth Controlled Line Follower Robot Using L298N Motor Driver
  4. Arduino UNO Bluetooth Controlled 4WD Robot Car Using L298N Motor Driver
  5. Arduino UNO Multi-Sensor Obstacle Avoidance & Bluetooth Controlled Robot Car Using L298N
  6. Raspberry Pi Motor Control Robot (L298N + Li-ion)
  7. RC Car Simulation with L298N Motor Driver and Joystick Control using Arduino (CirkitDesign Simulation)
  8. Raspberry Pi Robotic Arm Control System with Camera Module and Motor Driver – Smart Automation & Vision-Based Robotics Project
  9. ESP32-Based 4WD Robot Car Using Dual L298N Motor Drivers – Circuit Diagram and IoT Control Project

LORA & WIRELESS COMMUNICATION PROJECTS
  1. Arduino LoRa Communication Project Using Adafruit RFM95W LoRa RadioArduino Nano with RFM95 SX1276 LoRa
  2. Arduino Nano with RFM95 LoRa SX1276 Module – Long Range Wireless Communication Project
  3. Arduino Nano Digital Clock Using DS3231 RTC and TM1637 4-Digit Display – Circuit Diagram and Project Guide

 LED, LIGHTING & DISPLAY PROJECTS
  1. Arduino UNO Controlled NeoPixel Ring Light Show
  2. Wi-Fi Controlled NeoPixel Ring (ESP8266)
  3. Chained NeoPixel Rings with Arduino – Addressable RGB LED Control Project
  4. Arduino Nano-Controlled Lighting System with Gesture and Sound Interaction
  5. Raspberry Pi GPIO Multi-LED Control System – Beginner-Friendly Embedded Electronics Project
  6. 4 Channel Relay Module with Arduino UNO

 SENSOR & DETECTION PROJECTS
  1. Arduino UNO Color Sensor + Proximity System (TCS3200 + Inductive)
  2. Arduino Color Detection Project Using Adafruit TCS34725 RGB Color Sensor
  3. Arduino Gas Leakage Detection and Safety Alert System Using MQ-2 Gas Sensor
  4. MQ-135 Air Quality Detector Using Arduino | Cirkit Designer Simulation Project
  5. Pulse Sensor Using Arduino – Complete Guide with Simulation 
  6. HX711 Load Sensor Demo Using Arduino | Digital Weight Measurement Project
  7. Track Time with DS1307 RTC and Display on Arduino Uno with 16x2 LCD | Cirkit Designer Project
  8. Parking Sensor Simulator using Arduino Uno and HC-SR04 Ultrasonic Sensor

 FUN & INTERACTIVE PROJECTS
  1. Pong Game with Arduino UNO and OLED Display – Project Explanation
  2.   Arduino UNO Bluetooth-Controlled Servo Motor System
  3. Arduino UNO-Based Interactive Touch and Distance Sensing System with LED Indicators and Servo Control

 INDUSTRIAL / AUTOMATION PROJECTS
  1. Arduino UNO Smart Waste Sorting System Using Ultrasonic Sensor, Moisture Sensor, Servo, Stepper Motor and LCD
  2. Arduino-Based Smart Waste Segregation System Using Metal, Plastic and Moisture Sensors with Stepper and Servo Control
  3. ESP32-Based Digital Weighing Scale Using 50kg Load Cell, HX711 Module and 16x2 LCD Display
  4. Arduino-Based Smart Toll Gate Automation System with RFID, GSM, Ultrasonic Sensor and LCD Display

  5. Arduino-Based Automatic Pill Dispenser Machine with LCD Display, Servo Motor and Buzzer Reminder

  6. Arduino UNO Smart Water Quality Monitoring System with pH Sensor, Turbidity Sensor and LCD Display

  7. Arduino-Based Ocean Cleaning Boat Robot with Dual IBT-2 Motor Drivers and Conveyor Belt System

  8. IoT-Based Accident Detection and Health Monitoring System Using Raspberry Pi with GSM, GPS and Camera Integration

  9. Raspberry Pi RFID and Keypad Based Smart Door Lock System with LCD Display and L298N Motor Driver

  10. Smart Shopping Trolley Using Arduino UNO & RFID | Automatic Billing System

  11. Arduino UNO Based Automatic Liquid Hand Sanitizer & Soap Dispenser System

  12. Arduino Based Robotic Weeding Machine with Ultrasonic Obstacle Detection and L298N Motor Driver

  13. Arduino UNO Based Biometric Electronic Voting System with LCD Display and Fingerprint Authentication

  14. Arduino UNO Based Electronic Voting System with ILI9341 TFT Display

Comments