generate pulse for metal detector

is it possible ?

Yes, the code word to search for: PWM (pulse width modulation).