Skip to content
Step by Step Internet 馃寪 Guides for learning to surf the Net

How to use a relay with your Arduino board to control the voltage of your projects? Step by step guide

If you want to know how to use a relay on Arduino to control the voltage of your electronic projects, you will have to continue reading this article to the end.

We will show you in the following paragraphs what are these components for in electronics and what are the criteria that you must take into account when choosing a model and use it on your arduino kit.

Don’t miss anything because We will also explain, in an easy way, the steps you must do to use a relay on your badge Arduino. Lastly, you will see the best relay projects you can use.

What is a relay and what are these components for in electronics?

A relay is an electromagnetic device that works as a switch and that is responsible for activating one or more contacts, which allow opening or closing circuits from the plate Arduino. In this way, a signal can be controlled in low or high power, the latter being very important for the management of motors or other loads.

It is composed of a coil (that surrounds a nucleus) that allows activating, through a armor, to one or more contacts. These transmit the intensity of the load to the terminals so that the relay is connected to the Arduino.

What should I keep in mind when choosing and using a relay for my Arduino kit?

The first thing you should know is that a relay has 2 circuits inside. The first works by receiving the signal and then connecting it to the low voltage circuit of the Arduino board, while the second circuit turns the current on and off.

This means that the operation of a relay requires a switching time, so it cannot be considered as a PWM type signal. That is, with a medium-high frequency. From this it follows that, although it is true that a relay can work with direct and alternating current loads, it cannot always be used in all types of projects, since it will depend on the signal strength with which you have to work.

Another issue that you should take into account when choosing a relay to suit your needs is the physical dimension what’s wrong with it. This being an important factor when choosing one or the other model. By last, the normal life of a relay is related to the amount of switching. This means that it has a limited useful life, so you should keep in mind a possible replacement in the future.

Learn step by step how to use a relay with your Arduino board without making mistakes

The step by step you will have to do to use a relay on your Arduino board without making mistakes is the following:

Assemble all the components

Assemble all the components

The first thing you should do is connect the pins Vcc and GND to same board connectors from Arduino. Then you will have to assemble the load to the terminal block, or to the connector (depending on the model), of 3 connections, taking into account that the positive pole must be connected to terminal C.

Then the other load town you will have to connect it to NO or NC connector. In this step You will have to choose if you want the secondary to deactivate when the relay stay open or closed. Finally, you will have to connect the pin that belongs to a signal to digital connector of the plate.

Enter the programming codes

Once you have assembled all the components with the Arduino board You will have to schedule it so that it works automatically.

The IDE codes are:

Start the serial port and then define a pin as the output:

Next, you will have to include pin up, and then on low.

For this you must write:

Get to know the best Arduino projects with relays that you can make yourself to practice

Get to know the best Arduino projects with relays that you can make yourself to practice

We show you below Best Arduino Projects You Can Use With Relay so that you can practice what you have learned yourself.

Let’s get started:

Turn on an LED with relay

This very simple project will help you take the first steps and practice incorporating a relay to turn off and on a led with Arduino, then you can modify it and turn on another 220V element. For this job you will need connect the Arduino’s ports to the ground and 5 volt pin. You will also need to assemble the digital pin with the relay signal, the common terminal will be connected to 5V, the positive of the led will connect with NO and the negative with NC.

After this, you will have to write the following codes to finish the programming:

This will make the loop function I know always run.

Then you must enter:

Candy Vendor

In this project you can, through an Arduino board, create a candy dispenser automatically. You will need one Arduino MKR WiFi 1010 board, a servo motor, an LCD screen, a relay and a generic buzzer.

The programming code is long, so we leave it in the following link: https://github.com/ronibandini/CleanAlfajor/blob/master/CleanAlfajor.ino

Fire extinguisher

Fire extinguisher

With Arduino you will be able to create a fire extinguisher that will automatically activate when its sensors detect smoke. You’re going to need a fire extinguisher, a Arduino UNO, relay and photocells. This project is a bit complicated for people who are just starting to explore the Arduino world, but it does not imply that it is impossible. It has several plans that you must execute as you go, so you will have to be careful to perform all the steps perfectly.

You can copy all the Arduino programming codes below: