### RELAY TUTORIAL

In general the microcontroller gives output as 5v, but in order to switch ON any home device we require 230v AC , so to get this we use device 'Relay'. Relay acts as mechanical switch.
Let’s have a look..

#### Relay:

I don’t want to make you bore, i just touch few topics which are essential for us in our next project.
There are different types of relays have been in the market , just we only concern with the SPST type of relay in this section.
I said you before Relays are used as Switch right, now let us look at its pins, working and connections.
The basic symbol  look something like this

It is similar to normal switch symbol, but a coil on its left. When we excite coil (i.e when we give certain voltage to coil) then point 'A' will be connected to point 'B'.
Relay which we are using is ‘SPST 5v DC’ rated relay, then we need to give 5v Dc to make coil to excite.
To know how it actually  work as switch,lets  analyze the below image

>>In the above fig,  1,2,3,4,5  are pins of the relay.
1 and 2 = coil pins,
3= common pin
4= Normally open pin(No)
5=Normally closed pin(NC)
'(i.e NC pin 5 always connected to pin 3 inside the relay so we will leave that pin(5) unconnected outside)

After excitation of coil the pin 3 will be connected to pin 4 leaving pin5 alone.

>> To excite the coil we need to connect coil to microcontroller pin through diode and transistor as shown above. It means if mc pin is high(1) then coil will be excited and switch will be ON if not OFF.

>>Observe the pins 5 and 4 , 4 is connected to the +ve of main power supply and 3 is connected to the +ve of our device(i.e bulb)

>> Connect -ve of the main power supply directly to the -ve of our device(i.e bulb).

>> It means if the microcontroller pin is high(1) > coil will be excited>switch will be on(i.e 3 and 4 will be shorted)> +ve of main power is connected to +ve of device(i.e bulb) > current will be flow though the device(i.e bulb) and it makes ON if not then OFF.

In this way it acts as a switch. Now we got a bright picture in our mind how it works.
Below fig shows the bottom view of the relay(spst 5v)

Observe two pins on right hand side and 3 pins on left hand side from the above fig. (i.e one common pin, two coil pins, one NC, one NO).
The problem with it is, we should know which pins are Coil pins and which one are switch pins and which one is common pin.

#### Finding pins of the Relay(Read note below before reading these steps):

We can find which pin is what by using Mulitmeter. Les see how to find them step by step.

>> switch your multimeter to the continuity mode

>> Touch one of the probe of multimeter(i.e red wire or black wire of multimeter)  to any one of the right side pins of relay.

>>Now one wire of multimeter left unconnected, so connect it  to left hand side pins one by one(i.e left side have 3 pins, touch multimeter wire to each pin one after the other) until we get beep sound.

>>If you dint get any beep sound then, multimeter probe which is connected to right hand side pin, remove it from that pin  and connected to other remaining pin of the right hand side. Again check other probe connecting to left side pins one by one until you get beep sound

>> Beep sound  at which pin(left side) we get, it is pin no. 3 and  pin which is connected to the multimeter on the right side is pin no. 5

>>We found one pin on the right hand side(i.e pin5) and remaining pin which is on the right side is pin 4

>>we found pin no. 3,4,5.. now remaining pins on left side are the pins 1 and 2 i.e coil pins, you can treat any pins as 1 and 2  or 2 and 1...

#### If you feel its difficult for you to follow above steps, just assume pin numbers as below..

[ Most important note: The section "Finding the pins of the relay" is strictly i have explained by keeping in mind  of 'spst 5v rated relay' , for other relays they may have different pins in right and left sides..  so to know the pins of them the basic concept is same but pins on left side and right side may differ. Better dont use these steps for knowing pins of other relays]

#### General Steps to find pins of any relay(you can skip these steps):

>> Set the multimeter in resistance mode
>>Only coil pins show non zero resistance value.
>>Remaining pins show either zero or infinite value.
>> Where we get beep sound they are common pin and Normally closed pin>> Check all pins using multimeter by trail and error method..
AUTHOR: YOUSTRON SIC