Metal detectors are devices that use electromagnetic fields to find metal items in the surroundings.
Making a metal detector can be fun for people who like electronics.
We can build a metal detector using an Arduino, a special chip called CS209A, LEDs, a buzzer, and other parts.
This detector will use LEDs and sounds to show us if there is metal nearby.
The proximity detector IC CS209A is used in the Arduino metal detector circuit in this article.
CS209A is a chip that is good for finding things that are close and detecting metal.
Coding with Explanation:
// Declare Arduino Pins
const int vinHi = 2;
const int vinLo = 3;
const int ledG = 4;
const int ledR = 5;
const int Buz = 6;
// Variable to detect state change
int metalState = 0;
// Declare Arduino Pin Mode
void setup() {
pinMode(vinHi, INPUT);
pinMode(vinLo, INPUT);
pinMode(ledG, OUTPUT);
pinMode(ledR, OUTPUT);
pinMode(Buz, OUTPUT);
}
void loop() {
metalState = digitalRead(vinHi); // Read the proximity detector signal
if (metalState == HIGH) { // No Metal detected
digitalWrite(ledG, HIGH);
digitalWrite(ledR, LOW);
digitalWrite(Buz, LOW);
} else { // Metal detected
digitalWrite(ledG, LOW);
digitalWrite(ledR, HIGH);
digitalWrite(Buz, HIGH);
}
delay(3000); // Wait for 3 Sec.
}
Explanation:
- The constant integer variables vinHi, vinLo, ledG, ledR, and Buz are used to specify the pin numbers on the Arduino board.
- Digital pins 2 and 3 are assigned to vinHi and vinLo, respectively.
- The purpose of these pins is to read input signals.
- Digital pins 4, 5, and 6 are assigned to ledG, ledR, and Buz, in that order.
- Three LEDs one green, one red and a buzzer are controlled by these pins.
- The state that is now being read from the vinHi pin is stored in the integer variable metalState.
- It decides whether or not metal is found.
- When the Arduino is powered on or reset, the setup() method is called once.
- Every pin may be configured with pinMode():
- Since vinHi and vinLo are utilized for signal reading, they are configured as INPUT.
- Since they are used to deliver signals to the LED and buzzer, ledG, ledR, and Buz are set to OUTPUT.
- After the setup() function is finished, the loop() function is called again.
- The digital signal from the vinHi pin is read by digitalRead(vinHi).
- The value is kept in metalState and can be either HIGH or LOW.
- The value of metalState is verified using the if statement:
- MetalState being HIGH indicates that no metal has been found.
- Using digitalWrite(ledG, HIGH), the green LED is activated.
- The red LED is turned off using digitalWrite(ledR, LOW).
- To turn off the buzzer, use digitalWrite(Buz, LOW).
- Metal has been found if metalState is LOW:
- The green LED is turned off using digitalWrite(ledG, LOW).
- Using digitalWrite(ledR, HIGH), the red LED is turned on.
- Turns on the buzzer using digitalWrite(Buz, HIGH).
- delay(3000) stops the loop() function’s execution for three seconds before starting again.
- As a result, there is a lag between state transitions.
Circuit Working:
Parts List:
Component | Specification | Quantity |
---|---|---|
Arduino UNO | – | 1 |
IC CS209A | Metal Detection IC | 1 |
5V Buzzer | – | 1 |
LED Red 5mm 20mA | – | 1 |
LED Green 5mm 20mA | – | 1 |
Coil Detector | 100µH, 40mm diameter, 50 turns by 0.4 mm insulated copper wire | 1 |
Preset 10k | – | 1 |
Resistor 10k 1/4 watt | – | 1 |
Resistor 1k 1/4 watt | – | 2 |
Capacitor 10µF | – | 1 |
Capacitor 2.2nF | – | 2 |
9V Battery | – | 1 |
The Metal Detector Circuit using Arduino is powered by the 9V battery.
The coil detector is powered by a square wave signal produced by the Arduino microcontroller.
An electromagnetic field produced by the coil detector interacts with metal items.
The sensor coil 100μH is composed of 0.4 mm insulated copper wire with 50 turns and a 40 mm diameter.
The coils inductance varies in response to the detection of a metal item, which modifies the square wave signals amplitude.
In order to provide a cleaner and more dependable detection, capacitors are employed to filter out undesired noise and interference from the incoming signal.
Resistors are used to restrict the amount of current that passes through parts, guarding against damage and guaranteeing correct operation.
The metal detectors sensitivity may be adjusted with presets.
You may modify the threshold for detection or the oscillating signals amplitude by changing the resistance value.
The op-amp circuit is used to filter and amplify the signal.
The IC CS209A reference sets a threshold voltage that the amplified signal is compared to.
The Arduino activates if there is no metal near sensor coil the LED green will glow, if you bring metal near to coil the LED red will glow and buzzer will make noise.
How to Build:
To build a Metal Detector Circuit using Arduino follow the below mentioned steps:
- Gather all the components as mentioned in the above circuit diagram.
- Connect IC CS209A pin 1 to pin 8 through a preset and a 10k resistor.
- Connect IC CS209A pin 2 to one end of a 100uH coil.
- Connect IC CS209A pin 3 to other end of 100uH coil and GND.
- Connect IC CS209A pin 4 to pin 2 on Arduino UNO.
- Connect IC CS209A pin 5 to pin 3 on Arduino UNO.
- Connect IC CS209A pin 6 to GND through capacitor 2.2nF.
- Connect IC CS209A pin 7 to positive supply of 9V battery.
- Connect 9V negative supply to GND, and connect a capacitor 10uF from pin 7 to GND.
- Connect a 5V Buzzer one positive leg to pin 6 on Arduino board, and other leg to GND.
- Connect a pull-up resistor of 1k across pin 3 on Arduino board and the positive line.
- Connect a pull-up resistor of 1k across pin 2 on Arduino board and the positive line.
- Connect LED Red anode leg to pin 5 on Arduino board and cathode leg to GND.
- Connect LED Green anode leg to pin 4 on Arduino board and cathode leg to GND.
- Connect a capacitor 2.2nF from pin 2 and pin 3 of IC CS209A.
Conclusion:
Detecting metallic items is made easy and accurate with this metal detector circuit that uses an Arduino board and the CS209A integrated circuit.
The detection is dependable since it makes use of a coil, signal conditioning elements, and the CS209A IC.
The circuits usefulness is improved by the Arduinos processing of the signal and provision of both visual and auditory feedback.
This project offers a basis for future research into metal detection and sensor-based applications in addition to being a useful example of electronics and programming in action.
Leave a Reply