Arduino Uno KY-036 Metal Detector: Industrial Proximity Sensing
Professional KY-036 electromagnetic induction sensor detects ferrous/non-ferrous metals 1-10cm range through LC oscillator frequency shift. Hall effect + comparator outputs digital HIGH on proximity with analog A0 proportional to field strength and onboard sensitivity potentiometer.
50Hz-10kHz oscillation coil generates eddy currents in targets producing detectable field disturbance. 3.3-5V operation, 15mA current, digital pin 2 interrupt captures <1ms response for high-speed triggers.
Production Components Specification
- Arduino UNO R3 interrupt capable
- KY-036 Metal Touch Sensor Module
- Male-to-male jumper wires (4 pieces)
- Solderless breadboard prototyping
- Ferrous/non-ferrous test targets
- 220Ω buzzer/LED driver resistor
Dual Output Sensor Interface Configuration
VCC: Arduino 5V power rail
GND: Arduino GND
DO (Digital Out): Arduino Digital Pin 2 (HIGH = metal detected)
A0 (Analog Out): Arduino Analog Pin A0 (0-1023 strength)
Blue potentiometer clockwise increases sensitivity (1cm→10cm range). Red LED indicates detection.
// Arduino Uno KY-036 Metal Sensor - Professional Implementation
// Pin 2: Digital HIGH=DETECTED, A0: Analog strength 0-1023
const int sensorDO = 2;
const int sensorAO = A0;
const int buzzerPin = 8;
const int statusLed = 13;
volatile bool metalDetected = false;
void setup() {
Serial.begin(9600);
pinMode(sensorDO, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(statusLed, OUTPUT);
attachInterrupt(digitalPinToInterrupt(sensorDO), metalISR, RISING);
Serial.println("KY-036 Metal Detector Active");
Serial.println("Touch metal plate to test");
}
void loop() {
int strength = analogRead(sensorAO);
if(metalDetected || strength > 200) {
digitalWrite(statusLed, HIGH);
tone(buzzerPin, 2000 + strength, 100);
metalDetected = false;
Serial.print("*** METAL DETECTED *** Strength: ");
Serial.print(strength);
Serial.println(" /1023");
} else {
digitalWrite(statusLed, LOW);
noTone(buzzerPin);
}
delay(50);
}
void metalISR() {
metalDetected = true;
}
Arduino IDE Production Sensor Deployment
Upload interrupt-driven firmware with analog strength monitoring. Sensitivity pot adjusts 1-10cm ferrous detection range.
Serial Monitor + buzzer/LED confirm detection events with signal strength.
Advanced Discrimination & Sensitivity Calibration
// Metal Type Detection by Response Time
const unsigned long sampleWindow = 10;
int peakStrength = 0;
void loop() {
unsigned long start = millis();
int samples = 0;
int total = 0;
while(millis() - start < sampleWindow) {
int strength = analogRead(sensorAO);
total += strength;
peakStrength = max(peakStrength, strength);
samples++;
}
float avgStrength = total / (float)samples;
if(peakStrength > 400) {
String metalType = (avgStrength > 600) ? "FERROUS" : "NON-FERROUS";
Serial.print("METAL: ");
Serial.print(metalType);
Serial.print(" Peak:");
Serial.print(peakStrength);
Serial.print(" Avg:");
Serial.println(avgStrength, 0);
}
}
KY-036 Electromagnetic Operating Principle
Colpitts LC oscillator (10kHz) frequency shifts 1-10% near metals. Comparator threshold triggers digital output. Analog follows envelope detection.
Industrial Detection Applications
Non-contact door switches
Security weapon detection gates
Automated assembly line part presence
// Industrial Part Sorting by Metal Detection
const int conveyorPin = 9;
const int rejectPin = 8;
unsigned long detectTime = 0;
void loop() {
if(digitalRead(sensorDO) == HIGH) {
detectTime = millis();
}
if(millis() - detectTime < 500) { // Recent detection
digitalWrite(rejectPin, HIGH); // Reject metal
digitalWrite(conveyorPin, LOW);
Serial.println("METAL PART - REJECT");
} else {
digitalWrite(rejectPin, LOW);
digitalWrite(conveyorPin, HIGH); // Accept plastic
}
}
Production Sensor Performance
- 1-10cm ferrous detection range
- 0.5-8cm non-ferrous
- 1ms interrupt response
- 0-1023 analog strength
- Adjustable sensitivity pot
Field Calibration & Testing
Ferrous coin 5cm = 800 ADC; aluminum foil 3cm = 600 ADC. Pot CCW increases range. Shield coil from EMI.