Use the mouse or your finger to move the metal detector.
When the detector is maxed out, click/tap to dig up the metal object.
Look inside - the code is actually quite simple.
Notes & Credits
Thanks to @papipupepappa for the original project Metal Detector.