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.
📋 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.
How it works
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.
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).
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
✨ Key Features
⚡ Circuit Diagram
The schematic below shows all connections between the Arduino UNO, TCS3200 color sensor, inductive proximity sensor, and the LED indicator.
Simplified schematic — see wiring table below for exact pin mapping
🔌 Pin Wiring Reference
TCS3200 Color Sensor → Arduino UNO
| TCS3200 Pin | Arduino Pin | Direction | Purpose |
|---|---|---|---|
| S0 | D4 | OUT from Arduino | Frequency scaling bit 0 |
| S1 | D5 | OUT from Arduino | Frequency scaling bit 1 |
| S2 | D6 | OUT from Arduino | Photodiode filter select bit 0 |
| S3 | D7 | OUT from Arduino | Photodiode filter select bit 1 |
| OUT | D8 | IN to Arduino | Frequency pulse output |
| VCC | 5V | Power | Module power supply |
| GND | GND | Ground | Common ground |
Inductive Proximity Sensor → Arduino UNO
| Sensor Wire | Connection | Notes |
|---|---|---|
| Brown (VCC) | External 12V + | Sensor needs 6–36V — do NOT use Arduino 5V |
| Blue (GND) | Common GND | Shared with Arduino GND |
| Black (OUT) | D2 (Arduino) | Digital signal — NPN pulls LOW when metal detected |
LED Indicator → Arduino UNO
| LED | Connection | Notes |
|---|---|---|
| Anode (+) | D13 via 220Ω resistor | Current-limiting resistor essential |
| Cathode (−) | GND | Common ground rail |
pinMode(2, INPUT_PULLUP)) and invert your logic: LOW = metal detected, HIGH = no metal.
🛠️ Step-by-Step Build Guide
💻 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.
/* 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); }
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
Comments
Post a Comment