Introduction: Interface Relay With Arduino

Relay is a electrically operated switch. 12V relay is used to isolate electrical load using micro-controllers.Relay have two configuration NO(normally open)NC(normally close),relay have coil which is energize by 12v ,when coil energized switching action takes place ,based on NO-NC configuration .IF relay is NO configuration then when coil is energize switching action takes place from NO-NC then load will be connected.

Step 1: Hardware


BC548 is general purpose NPN bipolar junction transistor ,this transistor act as a driver to pulls the relay ON.Base is connected with micro-controller in series with resister,Emitter to ground,Collecter to relay

The purpose of diode in relay circuit is to protect transistor from back emf from relay supply


In this circuit negative of the lamp is connected with relay NO and NC is connected with battery negitive side and other end of lamp positive is connected with battery positive side ,when switch is pressed relay get energized and lead change position from NC to NO,then lamp will turn on


const int buttonPin = 13; // the number of the pushbutton pinconst

int relayPin = 3; // the number of the relay pin// variables will change:

int buttonState = 0; // variable for reading the pushbutton status

void setup()

{ // initialize the LED pin as an output:

pinMode(relayPin, OUTPUT); // initialize the pushbutton pin as an input:

pinMode(buttonPin, INPUT);


void loop()

{ // read the state of the pushbutton value:

buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed.

// if it is, the buttonState is HIGH: if (buttonState == HIGH)


// turn relay on:

digitalWrite(relayPin, HIGH);




// turn relay off:

digitalWrite(relayPin, LOW);



Step 3: Output