Menu Close

Transistor and Relay with Arduino.

This tutorial explains following concept, Transistor Switching, Working of Relay, Switching with relay on Arduino,Motor control on Arduino using Relay.

1. Introduction:

This tutorial explains following things-

  1. Switching with NPN transistor.
  2. Working and concept of Relay
  3. Switching by relay.
  4. Relay and Arduino
  5. Motor control by Relay on Arduino

1.1 Relay:

Following Video of Robo India explains working and concept of relay-

To use Relay with micro controller we need Transistor also for switching.

1.2 46ND006-P:

This is the relay we are going to use. This relay has got two poles, means there are two switches but both are trigged by a single Coil thus they operate simultaneously. Following Diagram will give you better understanding about the relay we are using.

2. Required Hardware

Following Hardware will be required to perform the example of this tutorials.

S.No.ItemQuantity
1 Arduino UNO 1
2 Breadboard 1
3 2 Pole Relay 1
4 DC Motor 1
5 Diode 1
6 NPN Transistor 1
7 LED (Different Colors) 5
8 Resistor 1k 6
9 Jumper 13

3. Building Circuit – 1 (Understanding of Relay)

This circuit is to make you understand the concept of relay. Our relay has got two poles, thus we have connected 4 LED to this. Two at Normally Connected pins and two are normally open pins. One status LED is also there. The Status LED tells that Relay is on of Off. If Status LED is on it means that relay is on (Common is connected to NC.) and vice versa.

Red LED- Statuts LED of Relay

Yellow LED – Connected to NC terminal of Relay

Green LED – Connected to NO terminal of Relay

Conclusion we can draw –

If red is off – means relay is off – means – Common terminals of Relay are connected to NC – Thus Yellow  LEDs are ON.

If red is ON – means relay is ON – means – Common terminals of Relay are connected to NO – Thus Green LEDs are ON.

Video will help you to understand.

here is the schematic:

4. Programming:

We don’t need any special programming to operate Relay of Transistor, Simple Digital output programming is required. So the programme we have added here is as same as in our other tutorial of Digital Output – LED Blinking. The same codding is used throughout the tutorial.

You may download code (Arduino Sketch) from here.

// Digital output tutorial by ROBO INDIA
// www.roboindia.com
// Digital output is taken on a LED that remains ON for one second and 
// OFF for another.

// Defining Pin 2 as LED.
const int LED = 2;  // from the circuit we can see that we have connected LED on Pin 2


void setup() {                
    pinMode(LED, OUTPUT); // Defining LED pin as OUTPUT Pin.   
}

// Below mentioned code runs for ever(infinite loop)
void loop() {
  digitalWrite(LED, HIGH); // LED gets turned ON (1/HIGH/+5V)
  delay(1000);             // Waiting for one second. 
  digitalWrite(LED, LOW);  // LED gets OFF (0/LOW/0V/GND)
  delay(1000);        // here and above Delay is in mili second (1000 = 1 second)
}

5. Circuit -2 (Motor control on Arduino using Relay):

As we have mentioned earlier that the codding is same for the entire tutorial. Here we are controlling one DC motor on Arduino board. Motor consumes more power than the other circuit thus you will need separate Power supply to run a motor. It will not run on Laptop/PC’s USB.

The circuit you will need is here –

here is the schematic of above circuit:

7. output:

Here is the output of this tutorial. Above code is implemented on Robo India R-Board and Arduino UNO Both.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

Leave a Reply