a relay is a simple device. when it comes to the Ardino, it has three parts. coil power, control power and contacts power.
the main part is the coil. this is a coil. an coil is coiled wire. you may know of a coil because they are used in motors. solenoids. speakers, electro-magnets, and, yup, relays. Some motors can be generators and generators have coils too.
so, read on coil basics.
now, you have to run POWER to the coil. in most cases, you should never attempt to power a coil from an Arduino pin. speakers or buzzers, maybe, motors NEVER. relays, NEVER. what happens is that you have to drive the coil with power and once it reaches a point, there is an electromagnetic field that is created. you changed the input power into a different form of energy.
when you stop driving that coil and the magnetic field collapses, it turns into an uncontrolled generator and that magnetic field will collapose adn charge the coil, it can charge the coil and the coil can deliver voltages that are MUCH higer than you put into the coil. this is called EMF, or in the case of a motor where the magnetic field is collapsing, Back-EMF.
where does it go ? depends where you power the coil, if you tried to power it from a pin on the Arduino, it will go back into the arduino. this will often destroy the pin if not the whole Arduino.
we we do is to add a Diode in reverse. it is blocking when under normal use, but when the back-emf spike happens, the diode shorts the coil back to itself.
DRIVING THE COIL :
we recomend you use a transistor or a FET. there are a lot of resutls to such a google search.
basicly, you have a resistor between your pin and the device. in the case of a transisor, you have to calculate power for the coil and then use a ratio of controlled power and input power. you have to input power to the transistor in the correct ratio to make it work. the beautiful thing is that you have to provide a tiny fraction of the power, milliAmps, to driver amps. the ardino is designed for this. as for an FET, you only need to provide voltage, so it is MUCH more efficent than a transistor on the Ardino side.
when you use an FET or transistor, (I' refer to them as FET/T ) you really only care what you have to do to make it work. the FET/T can control 100 VOLTS, but you only need to feed it a tiny signal. for the Transistor, you have to feed it a current proportional to the power, but for an FET (this is sloppy engineering) you have to feed it voltage equal to the supply voltage. since you cannot provide 100 volts from a common chip, they make special FET's that work on LOGIC LEVEL, or 5 volts. this is also TTL in case you see that term. you feed it 5 volts and internally, it can control the 100 volts.
in many cases, the model will have an L in it. an IRF530 does not, an IRL530 does. and whomever is packaging the starter kits with a IRF530 should have someone step on their foot.
as you can see, there is a great deal of isolating the coil from the Ardino. So much so that pople want to use more isolation, such as an opto-isolator. isolation means that the two circuits NEVER - EVER, that is like they never share any wiring, incluidng grounds.
however, the cheap e-bay relays have a common ground with an opto. pretty silly design.
so, now you have a coil that creates a magnetic field from one power supply, NOT the same power supply as the Arduino and NOT teh same power supply as the rest of the sensitive electronics unless you have some filtering between them.
and you have a control signal that is not on the same power supply as the coil.
that leaves the contacs from the relay. the relay coil creates a magnetic field. that electromagnet pulls on a plate that is connected to contacts. those contact are isolated from the coil and do not share any common connection. they can be designed for massive amps or micro-amps. we do not care because they are isolated from the control side wiring.