Why bother making a metal sensor yourself? Metal sensor modules are already available which can be easily interface with any microcontroller.
Google “hall effect metal proximity sensor”. The module produce logic 1 when detect, otherwise logic 0. hence it can be directly connected to any of the digital pin.