How to Control a Relay Using an Arduino Uno

How to Control Arduino Relay

How to Control Relays Using Arduino – In many applications, Relays are the main component used. For example, turning on the lights automatically, changing the polarity of the automatic voltage, timers and others that are triggered by the microcontroller.

One of the advantages of relays is that we can connect or disconnect electricity with high current and voltage with only 5V logic commands.

Arduino Digital Pins can be used to control relays, because the voltage on these digital pins can be 5V and 0V.

Before we control relays using Arduino, we have to divide relays into two types. What we want to control is the relay module or the relay only.

Controlling Arduino Relay Module

If we want to control the relay module, the method is very easy. On the relay module, there are 3 input pins. The 2 input pins are used to power Vcc and Gnd. While the other 1 is for the relay control input, 5V (HIGH) for the active relay and 0V (LOW) for turning off the relay.

The picture of the relay and arduino module circuit can be seen as follows;

Controlling Relays Without an Arduino Relay Module

If you want to use only relays, then there are 3 additional components that you must use. First resistors, transistors and diodes. For an example of a circuit and calculation of a BJT transistor that will be used as a switch, you can read the article here.

How to Control a Relay Using an Arduino Uno

You can replace the relay in this circuit with other types of relays such as te connectivity schrack, omron relay, panasonic relay and others.

To test the relay, you can simply use the Blink program that is included in the Arduino IDE. However, for those of you who are new to Arduino, please change the Delay value to 5 seconds so that the turn on and off is not too fast.

Program:

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(5000);              // wait for 5 second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(5000);              // wait for 5 second
}

That’s it. Hopefully this Control a Relay Arduino article is useful.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top