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 see how to activate and deactivate a relay output. So, we will learn how to set this output of an industrial controller Arduino thanks to Arduino automation.
Latest Posts
What is a Relay
A relay is a controlled switch that is used to select either one input signals 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 PLC, and we are going to use this basic example to change the relay of our Programmable Logic Controller 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!
How to Set Relay Output with an industrial Arduino based PLC