Let us now understand basics of Relay and then will move on to the interfacing part of Relay with Arduino Uno.
Relay
A relay is an electrically operated switch. It consists of a set of input terminals for a single or multiple control signals, and a set of operating contact terminals. The switch may have any number of contacts in multiple contact forms, such as make contacts, break contacts, or combinations thereof.
Interfacing Relay with Arduino
Components Required:
Arduino Uno with usb cable
Relay module and dc pump
Jumper wires (Male to Male (3))
Extension wire
9V battery
Breadboard (optional)
Step by step Connections
Connect the Signal pin of relay to the Digital pin 2 of the Arduino uno
Connect the VCC pin to the +5v of Arduino
Connect the GND pin to the GND of Arduino
Connect the +ve line from the battery to the Normally OPEN or NO port
Connect one terminal of the motor or pump to the relays COM port
Connect the other terminal of the motor to the –ve line of the battery
Code for Interfacing the Relay
Define the Pin Mode in the void Setup
Define the logic in the void Loop
Functions used in this example:
pinMode(Pin_Number, IN/OUT); to set the mode i.e. input or output for example pinMode(3,OUTPUT);
digitalWrite(Pin_Number,LOW/HIGH); to set the pin as High or low for example digitalWrite(3,LOW);
delay(microseconds) to put a time delay between two instructions. For example delay(1000) i.e. 1 sec delay
Comments