The principle of a metal detector is quite simple.
Inside the machine are wire coils.
A transmitter sends an electronic current through the coils.
The current flow goes from clockwise to counterclockwise and bake to clockwise again.
This current creates an electromagnetic field.