Arduino relay allows you to connect devices operating in relatively high current or voltage modes.
We can not directly link the Arduino board with powerful pumps, motors, even an ordinary intense bulb the board is not equipped for such a load and does not operate. That is why we’re going to have to add a relay to the circuit you can find in any project.
In this article we will talk about what relays are, how you can connect them to your Arduino project.
Introduction to Relay
A relay is a gateway that allows you to connect together electrical circuits with completely different parameters.
The relay in Arduino turns on or off external devices, in a certain way closing or disconnecting the separate electrical network into which they are connected.
With the help of Arduino and relays, we control the process of turning on or off the same way we turn the lights on or off at home giving a command to close or open.
Characteristics
It module has two characteristics.
- Channels – Channels are based on how many devices to be connected.
- Power – Power based on Microcontrollers.
Pin Out diagram of Relay
This is a 2 channel relay where it has 2 relays. The connection on the right side indicates the connection to be done with the Microcontroller(Arduino).
Similarly, the connection on the left side with the devices like Bulb, motor etc.
Connections(Arduino)
- VCC – To connect to the supply of the Arduino
- GND – To connect the ground to the Arduino
- IN1 – To control the first relay, should be connected to the digital pin of Arduino
- IN2 – To control the second relay, should be connected to the digital pin of Arduino
On the other set of pins consists of JD-VCC is used to powers the electromagnet of the relay.
Connections(Devices)
- NO – Normally Opened, If connected to NO the load remains disconnected before the trigger
- NC – Normally Closed, The other end of the load is either connected to NO or NC. If connected to NC the load remains connected before the trigger
- COM– Common, It is connected to one End of the Load that is to be controlled
Relay Example
Code
const int relPin = 3;
void setup() {
pinMode(relPin, OUTPUT);
}
void loop() {
digitalWrite(relPin, HIGH);
delay(1000);
digitalWrite(relPin, LOW);
delay(3000);
}
This program and the connection blinks a bulb every 1 second, same as Blinking LED but with an bulb