help to trigger a relay by compass

I am new to arduino, i bought arduino r3 with starter kit and a hmc 6352 compass.
Can any one help me to make compass to arduino to trigger a rely with code.
I have window 8.1 on my laptop.
thank you

moderator: updated title

Well have you Googled? There are some examples of using that compass with Arduino, like this for example. (I haven't ever used on myself.....)

But if you're brand new to Arduino you should probably do the starter kit examples first.

What do you mean when you say that the compass must trigger a relay?- switch the relay depending on direction? If so, get the compass going first on its own (after you have done the starter kit examples), then perhaps use an "if" to switch on the built-in led on pin 13 based on the direction.

Then lastly look how to hook up a relay: there are lots of examples like this. Then just use your led code to switch the relay instead.

I am planning to make a magnet detector maximum distance 3 meters
.is pin 13 an outlet voltage and what is the output voltage of it, does it relies on the strength of the north and south poll of the magnet ? if so, would it possible to control the output voltage of pin 13 by adding a zenor diod or a transistor switch to it, to make detecting only for nearby magnet. Also you said that I can put a led code , is it with the the hmc 6352 compass code or on its own .

Pin 13's a normal digital pin on the Arduino.

You need to step back I think: put your compass module back in its box and do the examples for your starter kit, or here.

rafaa , I would suggest you use a Hall effect sensor to sense a magnetic field instead of the compass if you simply
want to sense a magnetic field.
This would involve using an Analogue pin , not sure if it would work at 3 meters though ?

hi, i thing the Hall effect sensor is sensing a magnetic field no moor than 2 inch distance, if there is a way to make it sense longer or if any one knows please tel us.

hi, i thing the Hall effect sensor is sensing a magnetic field no moor than 2 inch distance

That depends entirely on the strength of the magnet, since it's the strength of the field that causes the sensor to trip, not the distance from the magnet.