Arduino UNO-Based Color Sensor and Proximity Detection System with TCS3200 and Inductive Sensor

Arduino UNO Color Sensor & Proximity Detection System (TCS3200 + Inductive) | MakeMindz
Arduino UNO TCS3200 Inductive Sensor Color Detection Automation

Arduino UNO Color Sensor
& Proximity Detection System

A dual-detection system combining the TCS3200 color sensor with an inductive proximity sensor for real-time color identification and metal object detection — ideal for smart sorting and industrial automation.

🕐 30–45 min build 🔧 Beginner–Intermediate 💡 LED + Serial output 🏷️ MakeMindz.com

📋 Project Overview

This project integrates two sensing technologies on a single Arduino UNO: the TCS3200 color sensor reads the RGB composition of any object placed in front of it by converting filtered light into frequency signals, while the inductive proximity sensor detects nearby metallic objects without any physical contact. Together they form a compact dual-detection platform suitable for conveyor sorting, industrial inspection, and STEM prototyping.

ℹ️ Detection results are printed to the Serial Monitor at 9600 baud and optionally indicated via an LED wired to a digital output pin.

How it works

Step 1

Color detection

TCS3200 filters red, green, and blue light using photodiodes. The Arduino reads pulse width from the OUT pin to measure each channel's frequency.

Step 2

Metal detection

The inductive sensor generates an oscillating electromagnetic field. A nearby metal object alters the field and pulls the digital output LOW (or HIGH depending on module type).

Step 3

Combined response

The Arduino evaluates both inputs every loop cycle and outputs the result via Serial monitor and LED — or triggers a relay/servo for automated sorting.

🔧 Components Required

1
Arduino UNO
Any standard R3 or clone board
1
TCS3200 Module
Color-to-frequency converter with onboard LEDs
1
Inductive Proximity Sensor
NPN or PNP type, 6–36V, detects ferrous metals
1
LED + 220Ω Resistor
Status indicator for proximity alert
1
Breadboard
Half-size or full-size for prototyping
Jumper Wires
Male-to-male and male-to-female sets
1
External 12V Supply
Required for NPN inductive sensor coil power

Key Features

✔ Dual sensing (Color + Metal)
✔ Contactless proximity detection
✔ Real-time LED indication
✔ Serial monitor output
✔ Expandable to servo / relay sorting
✔ Suitable for conveyor integration

Circuit Diagram

The schematic below shows all connections between the Arduino UNO, TCS3200 color sensor, inductive proximity sensor, and the LED indicator.

Arduino UNO D4 → S0 (TCS3200) D5 → S1 (TCS3200) D6 → S2 (TCS3200) D7 → S3 (TCS3200) D8 ← OUT (TCS3200) D2 ← Proximity OUT D13 → LED (+) 5V → TCS3200 VCC GND → Common GND TCS3200 Color sensor module S0 ← D4 S1 ← D5 S2 ← D6 S3 ← D7 OUT → D8 VCC ← 5V GND ← GND R G B Inductive Sensor NPN / PNP type VCC ← 12V ext. OUT → D2 (Arduino) GND ← Common GND LED Indicator + ← D13 (220Ω) - ← GND Common Ground Rail — Arduino GND → TCS3200 GND → Sensor GND → LED − 5V 12V ext. supply for sensor coil 220Ω in series

Simplified schematic — see wiring table below for exact pin mapping

🔌 Pin Wiring Reference

TCS3200 Color Sensor → Arduino UNO

TCS3200 PinArduino PinDirectionPurpose
S0D4OUT from ArduinoFrequency scaling bit 0
S1D5OUT from ArduinoFrequency scaling bit 1
S2D6OUT from ArduinoPhotodiode filter select bit 0
S3D7OUT from ArduinoPhotodiode filter select bit 1
OUTD8IN to ArduinoFrequency pulse output
VCC5VPowerModule power supply
GNDGNDGroundCommon ground

Inductive Proximity Sensor → Arduino UNO

Sensor WireConnectionNotes
Brown (VCC)External 12V +Sensor needs 6–36V — do NOT use Arduino 5V
Blue (GND)Common GNDShared with Arduino GND
Black (OUT)D2 (Arduino)Digital signal — NPN pulls LOW when metal detected

LED Indicator → Arduino UNO

LEDConnectionNotes
Anode (+)D13 via 220Ω resistorCurrent-limiting resistor essential
Cathode (−)GNDCommon ground rail
⚠️ NPN sensor output: Most inductive sensors are NPN open-collector type — they pull the output LOW when detecting metal. Enable the Arduino's internal pull-up resistor (pinMode(2, INPUT_PULLUP)) and invert your logic: LOW = metal detected, HIGH = no metal.

🛠️ Step-by-Step Build Guide

1
Prepare your breadboard and power rails
Place the Arduino UNO next to a half-size breadboard. Connect the Arduino's 5V pin to the breadboard's positive rail and GND to the negative rail. This gives you a clean 5V bus for the TCS3200 and the LED circuit.
2
Wire the TCS3200 color sensor
Connect TCS3200 VCC to the 5V rail and GND to the ground rail. Then wire the four control pins: S0 → D4, S1 → D5, S2 → D6, S3 → D7. Finally wire the output: OUT → D8 on the Arduino.
💡 The TCS3200 module usually has onboard white LEDs for illuminating the target. Make sure they face toward the object you're detecting.
3
Set frequency scaling in code before measuring
In setup(), set S0 HIGH and S1 LOW. This configures the sensor to output at 20% of full frequency scale — ideal for most microcontroller timers. This step is done in software but requires the pins to be wired correctly first.
4
Connect the inductive proximity sensor
The inductive sensor requires a 6–36V supply for its coil oscillator — connect Brown (VCC) to an external 12V DC supply. Connect Blue (GND) to the common ground shared with the Arduino. Connect Black (signal OUT) to Arduino D2.
⚠️ Never power the inductive sensor from the Arduino's 5V pin — it draws too much current and will damage the board or reset it.
5
Wire the LED indicator
Place a 220Ω resistor in series between Arduino D13 and the LED anode (+). Connect the LED cathode (−) to GND. The longer leg of the LED is the anode. The resistor prevents overcurrent through the LED.
6
Connect all grounds together
Tie Arduino GND, TCS3200 GND, the external 12V supply's negative terminal, and the LED cathode rail all to the same ground node on the breadboard. A shared ground is critical for reliable digital signalling between the sensor and the Arduino.
💡 Use the breadboard's negative rail as the common GND bus and run short wires from each module to it.
7
Upload the sketch and calibrate
Open Arduino IDE, paste the code below, and upload to the UNO. Open Serial Monitor at 9600 baud. Place known-colour objects (red, green, blue cards) in front of the TCS3200 and record the R, G, B frequency values. Update the threshold constants in the code to match your readings.
📏 Calibration is essential — frequency values vary with ambient light and sensor distance. Always calibrate with the sensor at a fixed distance (2–5 cm works well).
8
Test both sensors together
With power on, bring a metal object (coin, bolt) within 5 mm of the inductive sensor — the Serial Monitor should print "Metal detected" and the LED should light up. Place a coloured object under the TCS3200 — the RGB values and colour name should appear on serial. Adjust thresholds until identification is reliable.

💻 Full Source Code

Copy and paste into Arduino IDE. Calibrate the colour threshold values after wiring by reading known objects in Serial Monitor at 9600 baud.

ColorProximity.ino
/*
  Arduino UNO Color Sensor + Proximity Detection
  MakeMindz.com — TCS3200 + Inductive Sensor
  Outputs detected color and metal status to Serial Monitor
*/

// TCS3200 pin definitions
#define S0         4
#define S1         5
#define S2         6
#define S3         7
#define SENSOR_OUT 8

// Inductive proximity sensor pin
#define PROX_PIN   2

// LED indicator pin
#define LED_PIN    13

// Colour thresholds (calibrate for your environment)
#define RED_THRESHOLD   50
#define GREEN_THRESHOLD 50
#define BLUE_THRESHOLD  50

void setup() {
  Serial.begin(9600);

  // TCS3200 control pins
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(SENSOR_OUT, INPUT);

  // Set frequency scaling to 20%
  digitalWrite(S0, HIGH);
  digitalWrite(S1, LOW);

  // Proximity + LED
  pinMode(PROX_PIN, INPUT_PULLUP); // NPN sensor — active LOW
  pinMode(LED_PIN, OUTPUT);

  Serial.println("Color + Proximity System Ready");
}

void loop() {
  // Read RGB colour frequencies
  int red   = readColor(LOW,  LOW);   // S2=L, S3=L → red filter
  int green = readColor(HIGH, HIGH);  // S2=H, S3=H → green filter
  int blue  = readColor(LOW,  HIGH);  // S2=L, S3=H → blue filter

  Serial.print("R: "); Serial.print(red);
  Serial.print("  G: "); Serial.print(green);
  Serial.print("  B: "); Serial.print(blue);
  Serial.print("  → ");

  // Identify colour by dominant channel
  if (red < green && red < blue) {
    Serial.print("RED");
  } else if (green < red && green < blue) {
    Serial.print("GREEN");
  } else if (blue < red && blue < green) {
    Serial.print("BLUE");
  } else {
    Serial.print("UNKNOWN");
  }

  // Read proximity sensor (NPN: LOW = metal present)
  bool metalDetected = (digitalRead(PROX_PIN) == LOW);

  if (metalDetected) {
    Serial.println("  | Metal DETECTED");
    digitalWrite(LED_PIN, HIGH);
  } else {
    Serial.println("  | No metal");
    digitalWrite(LED_PIN, LOW);
  }

  delay(500);
}

// Read one colour channel from TCS3200
int readColor(int s2State, int s3State) {
  digitalWrite(S2, s2State);
  digitalWrite(S3, s3State);
  delay(100); // Allow sensor to stabilise
  return pulseIn(SENSOR_OUT, LOW);
}
Lower frequency values from pulseIn() mean more light of that colour is detected. The dominant colour has the lowest reading. Calibrate by placing a known red, green, or blue object and noting each channel's value.

🖥️ Run the Simulation

Test this circuit online before building the hardware using one of these platforms:

🏭 Applications

  • Industrial object sorting systems — sort items on a conveyor by colour and material type
  • Smart manufacturing prototypes — detect mixed metal and plastic components
  • Robotics competitions — autonomous colour-based path or object selection
  • STEM and engineering projects — teach sensor fusion and embedded programming
  • Automated inspection systems — flag defective or mismatched items in real time

Extensions & next steps

  • Add a servo motor to physically sort detected objects into bins
  • Integrate an I2C LCD to display colour and metal status without a computer
  • Replace the LED with a relay to trigger a pneumatic actuator for industrial sorting
  • Add a second TCS3200 module for top-and-side dual-angle colour reading
  • Log data to an SD card module for quality-control record keeping

© 2026 MakeMindz.com · Arduino UNO Color Sensor & Proximity Detection Tutorial · MIT Licensed

Built for STEM learners, robotics enthusiasts & IoT developers.

Comments

try for free