Get tutorials Arduino From Knowing To Utilizing V1.0 for Arduino

Lesson 17 Relay Module

Introduction

As we know relay is a device which is used to provide connection between two or more points or device in response to the input signal applied. In another words relay provide isolation between the controller and the device as we know devices may work on AC as well as on DC. However, they receive signals from microcontroller which works on DC hence we require a relay to bridge the gap. Relay is extremely useful when you need to control a large amount of current or voltage with small electrical signal.

 

Components

- 1 * SunFounder Uno board (or SunFounder Mega2560 board)

- 1 * USB data cable

- 1 * Relay module

- 1 * 3-Pin anti-reverse cable

 

Experimental Principle

Relay – There are 5 parts in every relay:

1. Electromagnet – It consists of an iron core wounded by coil of wires. When electricity is passed through, it becomes magnetic. Therefore, it is called electromagnet.

2. Armature – The movable magnetic strip is known as armature. When current flows through them, the coil is it energized thus producing a magnetic field which is used to make or break the normally open (N/O) or normally close (N/C) points. And the armature can be moved with direct current (DC) as well as alternating current (AC).

3. Spring – When no currents flow through the coil on the electromagnet, the spring pulls the armature away so the circuit cannot be completed.

4. Set of electrical contacts – There are two contact points:

.      Normally open - connected when the relay is activated, and disconnected when it is inactive.

.      Normally close – not connected when the relay is activated, and connected when it is inactive.

5. Molded frame – Relays are covered with plastic for protection.

Working of Relay

The working principle of relay is simple. When power is supplied to the relay, currents start flowing through the control coil; as a result, the electromagnet starts energizing. Then the armature is attracted to the coil, pulling down the moving contact together thus connecting with the normally open contacts. So the circuit with the load is energized. Then breaking the circuit would a similar case, as the moving contact will be pulled up to the normally closed contacts under the force of the spring. In this way, the switching on and off of the relay can control the state of a load circuit.

 

When we make the IO ports connected to the SunFounder board and the transistor outputs low level (0V) by programming, the transistor will conduct because of current saturation. The normally open contact of the relay will be closed, while the normally closed contact of the relay will be broken; when outputting high level (5V), the transistor will be cut off, and the relay will recover to initial state.

 

Experimental Procedures

Step 1: Build the circuit

 

Relay module

SunFounder Uno

s

8

“-”

GND

+

5V

 

 

Step 2: Program (Please refer to the example code in LEARN -> Get Tutorials on our website)

Step 3: Compile the code

Step 4: Upload the sketch to the SunFounder Uno board

Now, you may hear ticktock. That's the normally closed contact opened and the normally open contact closed.

 

Code 

/**********************************************/
const int relayPin =8; //the "s" of relay module attach to
/**********************************************/
void setup()
{
  pinMode(relayPin, OUTPUT); //initialize relay as an output
}
/***********************************************/
void loop()
{
  digitalWrite(relayPin, HIGH); //Close the relay
  delay(1000); //wait for 1 second
  digitalWrite(relayPin, LOW); //disconnect the relay
  delay(1000); //wait for 1 second
}
/*************************************************/


Copyright © 2012 - 2016 SunFounder. All Rights Reserved.


Previous chapter: Lesson 16 74HC595

Next chapter: Lesson 18 Stepper Motor

SunFounder
Feb 02 2016 at 03:09 am



© Developed by CommerceLab