Build a Simple Robotic Metal Detector (part four)

Arduino micro controller

This is part four of four in a series on how you can make a metal detecting sensor for your robot. If you have missed the previous article go here to view it:

Here is the code for the arduino that allows it to receive input from the metal detecting circuit.

//Begin Arduino code

// Programmer: Gunther Cox
// Created: 02/15/12
// Hardware setup instructions:
// Plug relay shield directly into arduino so that all pins line up.
// Attach 9 volt power supply to GND and +9V plugs of relay shield.

//  connect whatever you want to indicate metal is detected with (ex: an LED) to pin 4
int outPin1 = 4;
int detectorPin = 3;  // connect positive wire from circuit here
int detectorState = LOW; // we start, assuming no metal has been detected
int val;            // variable for reading the pin status

void setup() {
  pinMode(detectorPin, INPUT);        // declare sensor as input
  pinMode(outPin1, OUTPUT);    // declare relay as output
  digitalWrite(outPin1, LOW);
  digitalWrite(detectorPin, LOW);

void loop() {
  val = digitalRead(detectorPin);  // read input value and store it in val
  if(digitalRead(detectorPin) == HIGH) {
    // turn output pin on for one second
    digitalWrite(outPin1, HIGH);  // sets relay1 on
    delay(1000);                    // waits for 1 second
    digitalWrite(outPin1, LOW);   // sets relay1 off

//End Arduino code

Mounting the metal detector on the robot

There are a few important things to take into consideration when finally attaching the metal detector to the robot. First, any metal near or on the coil will effect the frequency, you must take this into account when you wind the coil. A small bracket will not make much of difference but it is better to use plastic brackets neat the coils. If you use a metal part and it moves too close to the coils it will alter the tuning. You will probably have to re tune the coils after you mount them on the robot.

You can feel free to adjust the number of turns that you use because they depend on the diameter of the search coil. When the two oscillators are well matched it should be possible by adjusting the brass nut in or out to bring the beat note to a halt or null.

The reference oscillator is much smaller than the search coil and should be attached as far away from the search coil as necessary.

When detecting objects some of the things to take into account are that you may only be able to detect some objects at very close range. The larger the object the easier it will be to detect and the bigger the coil the further it will detect objects but big coils are not good for detecting small objects. Another thing to remember is that if the search coil and reference coil are way off frequency you won't get any sound.

Note: You may need to adjust the reference oscillator every now and then if it stops working as well.

"Metal Detector FAQ's." White's Metal Detectors. 2011. Web. 09 Jan. 2012.
"Metal Detector Types." Metal Detectors. 09 Jan. 2011. Web. 09 Jan. 2012.
"HOW TO MAKE A METAL DETECTOR." Essex Metal Detectors. Saxons. Web. 09 Jan. 2012.