Our old math teacher famously said, “You have to take what you know and use it find what you don’t know.” The same holds true for a lot of microcontroller designs including [rgco’s] clever metal detector that uses very little other than an Arduino. The principle of operation is simple. An Arduino can measure time, a coil and a resistor will create a delay proportional to the circuit values, and metal around the coil will change the coil’s inductance. As the inductance changes, so does the delay and, thus, the Arduino can sense metal, as you can see in the video below.
The simple principle is also simple in practice. Besides the Arduino and the coil, there’s a single resistor. You want a small coil since larger coils won’t detect smaller objects. If you don’t want to wind your own coil, [rgco] suggests using a roll of hookup wire as long as the resistance is under 10 ohms.
You could omit it, but the original design has a buzzer and an electrolytic capacitor connected to generate a buzz in addition to the built-in LED indicator when metal is near. The LED also shows a blink pattern if the coil is open, too short, too long, or has too much resistance.
The biggest problem is that the poor Arduino needs to measure delays down in the nanosecond range. It can’t actually do this directly, so the code takes a ranging measurement to get in the ballpark and then produces appropriately-sized pulses and adds them up to get a better idea of the total delay. There are several videos in the post of a prototype and the final device built in a Tic Tac container, which you can see below.