INTRODUCTION
A relay is nothing but an electromagnetic switch. It is used to control a circuit from a long distance. It is a transducer, since it converts one form of energy to another. In this case, it converts electrical energy to mechanical energy.
A relay consists of 2 coils and a magnetic field generator. When the current flows through the coils, the magnetic field pushes the armature. Thus, the circuit is completed.
In this blog post, we will learn how to set a relay output in order to active and deactivated them.
Latest Posts
REQUIREMENTS
WHAT IS A RELAY
A relay is a controlled switch which is used to select either one input signal out of a number of input signals, or one output signal out of a number of output signals, a relay is a polarized electrical switch.
A relay is electrically equivalent to an open switch, but electrically controlled, relays are used where it is necessary to control a circuit by a separate low-power signal, or where several circuits must be controlled by one signal. Relays are used in control systems such as timers, analog computers, radar sets.
To know more about relays, Check this out >>
TESTING
To control the relays, we are going to power our Arduino based PLC, and we are going to use this basic example to change the relay every half second. In this example, the output of relay R0_1 is ON (switch closed) and OFF (switch open)
void setup() {
pinMode(R0_1, OUTPUT);
}
void loop() {
digitalWrite(R0_1,HIGH); // Opens the relay switch
delay(500); // Wait 500ms
digitalWrite(R0_1,LOW); // Closes the relay switch
delay(500);
}
Finally, in the Arduino IDE go to Tools and select the board, model and port, and you will be ready to upload your sketch!