This DIY Simple Sensitive Metal Detector using an Arduino Nano can be found on the Arduino Project Hub. When I first encountered it, some aspects of the build were a little vague. To get over a few problems, I investigated the design and have introduced a few updates based around readily available components. These are included in the full circuit diagram and parts list shown here. Upon building this project, I did run into a slight issue with it launching the self calibration code before the circuit voltages had stabilised. This is now fixed by adding a short delay and the updated code is included here.

 

The metal detector is a pulse induction type, its operating principles are well covered in other articles and can be easily found on the web. Full credit to Mirko Pavleski for this interesting project.

 

Parts list

The circuit diagram

The code for our metal detector 

// PI metal detector for arduino version_18_min (C) alex — 1967 201

int ss0 = 0;

int ss1 = 0;

int ss2 = 0;

long c0 = 0;

long c1 = 0;

long c2 = 0;

byte i = 0;

int sss0 = 0;

int sss1 = 0;

int sss2 = 0;

int s0 = 0;

int s1 = 0;

int s2 = 0;

 

void setup ()

{

DDRB = 0xFF; // port B – all out

DDRD = 0xFF; // port D – all out

delay (1000); //pause for Volts) to stabilise before calibration

 

for (i = 0; i <255; i ++) // calibration / calibration

{

PORTB = B11111111; // Sets port B pins to 1 and turns ON transistor. 

delayMicroseconds (200); // wait 200 microseconds

PORTB = 0; // Turns OFF transistor

delayMicroseconds (20);

s0 = analogRead (A0);

s1 = analogRead (A0);

s2 = analogRead (A0);

c0 = c0 + s0;

c1 = c1 + s1;

c2 = c2 + s2;

 

delay (3);

}

c0 = c0 / 255;

c0 = c0 – 5;

c1 = c1 / 255;

c1 = c1 – 5;

c2 = c2 / 255;

c2 = c2 – 5;

 

}

 

void loop ()

{

PORTB = B11111111; // Sets port B pins to 1 and turns ON transistor.  

delayMicroseconds (200); // wait 200 microseconds

PORTB = 0; // Turns OFF transistor.

delayMicroseconds (20);

s0 = analogRead (A0);

s1 = analogRead (A0);

s2 = analogRead (A0);

ss0 = s0 – c0;

 

if (ss0 <0)

{

sss0 = 1;

}

ss0 = ss0 / 16;

PORTD = ss0; // send to the indicator (send to LEDs)

delay (1);

 

ss1 = s1 – c1;

if (ss1 <0)

{

sss1 = 1;

}

ss1 = ss1 / 16;

PORTD = ss1; // send to the indicator (send to LEDs)

delay (1);

 

ss2 = s2 – c2;

if (ss2 <0)

{

sss2 = 1;

}

ss2 = ss2 / 16;

PORTD = ss2; // send to the indicator (send to LEDs)

delay (1);

 

if (sss0 + sss1 + sss2> 2)

{

digitalWrite (7, HIGH);

digitalWrite (6, HIGH);

digitalWrite (5, HIGH);

digitalWrite (4, HIGH);

digitalWrite (3, HIGH);

digitalWrite (2, HIGH);

digitalWrite (1, HIGH);

digitalWrite (0, HIGH);

delay (1);

sss0 = 0;

sss1 = 0;

sss2 = 0;

}

}