For an easy DIY metal detector setup, look no further than this project by creator “rgco.”
The handheld device uses a 20-60 turn coil of 26AWG enameled wire, connected across an Arduino Uno or Nano’s pins 8 and 10. A series of pulses is continuously sent out by pin 10, which are delayed in reaching pin 8 according to the inductance across the coil. As this coil approaches other metallic objects, the effective inductance changes, thus varying the delay in the signal reaching pin 10.
This effect is sensed by the Arduino, outputting chirps on a buzzer as audio feedback when metal is nearby. To convert it into a practical device, the Nano configuration is stuffed into a Tic Tac container, with the coil held at a distance with two skewer sticks.