【Use Relay with Arduino】Step by Step Guide ▷ 2022

If you want to know how to use a relay to control the voltage of your electronic projectsyou will have to continue reading this article until the end.

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

Do not miss anything because We will also explain, in an easy way, the steps you must take to use a relay on your plate Arduino. Finally, you will be able to see the best relay projects that 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 in charge of activating one or more contacts, which allow to open or close circuits of the plate Arduino. In this way, a signal can be controlled at low or high power, the latter being very important for driving motors or other loads.

It consists of a coil (which surrounds a nucleus) that allows to activate, by means of a armorto one or more contacts. These transmit the intensity of the load to the terminals for the relay to be connected on the circuit board 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 medium-high frequency. From this it follows that, although it is true that a relay can work with direct and alternating current loads, It can not always be used in all types of projectssince it will depend on the signal intensity with which you have to work.

See also  【Recover Gmail Password】Step by Step Guide ▷ 2022

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. Finally, the normal life of a relay is related to the number of switchings. 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 that you will have to do to use a relay on your Arduino board without making mistakes is the following:

Assemble all the components

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

Then the other charging people will have to connect it to NO or NC connector. In this step you will have to choose if you want that when the relay is deactivated the secondary stay open either closed. Finally, you will have to connect pin belonging to a signal to digital connector of the plate.

Enter 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:

const int pin = 9; void setup() {

Initialize the serial port and then define a pin as an output:

begin(9600); pinMode(pin, OUTPUT); }

Next, you will have to include the pin upand then in bass.

To do this you must write:

void loop(){ digitalWrite(pin, HIGH); delay(10000); digitalWrite(pin, LOW); delay(10000); }

See also  【 HOOTSUITE 】What is it and how is it used? + Cheats ▷ 2022

Get to know the best Arduino projects with relay that you can do yourself to practice

We show you below the best ones you can use with relay so that you can practice what you have learned yourself.

Let’s start:

Turn on an LED with relay

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

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

int relay=8; void setup() { pinMode(8, OUTPUT); }

This will make the loop function I know always run.

Then you must enter:

void loop() { digitalWrite(relay, HIGH); delay(1000); digitalWrite(relay, LOW); delay(1000); }

candy vendor

In this project you will be able, through an Arduino board, create a candy dispenser automatically. you’re going to need one Arduino board MKR WiFi 1010a servo motor, an LCD screen, a relay and a generic buzzer.

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

Fire extinguisher

With Arduino you will be able to create a fire extinguisher that will activate automatically when its sensors detect smoke. You will need a fire extinguisher, a , 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 progress, so you’ll have to be careful to perform all the steps perfectly.

All the Arduino programming codes can be copied below:

int lightPin = 0; int latchPin = 11; int clockPin = 9; int dataPin = 12; int lightPin2 = 1; int lightPin3 = 2; int lightPin4 = 3; int lightPin5 =4; int ledsLit = 0; int leds = 0; int readingEnough1 = 0; int readingEnough2 = 0; int readingEnough3 = 0; int readingEnough4 = 0; int bias = 0; int ringerlight = 8; int readAll = 0; void setup() { pinMode(ringerlight, OUTPUT); begin(9600); digitalWrite(ringerlight, LOW); } void loop() { readAll = 0; int reading5 = analogRead(lightPin5); /bias = reading5; int reading = analogRead(lightPin); if (reading > (150+bias)) readingEnough1 = readingEnough1 + 1; delay(20); int reading2 = analogRead(lightPin2); if (reading2 > (150+bias)) readingEnough2 = readingEnough2 + 1; delay(20); int reading3 = analogRead(lightPin3); if (reading3 > (150+bias)) readingEnough3 = readingEnough3 + 1; delay(20); int reading4 = analogRead(lightPin4); if (reading4 > (150+bias)) readingEnough4 = readingEnough4 + 1; delay(20); print(reading); print(” : “); print(reading2); print(” : “); print(reading3); print(” : “); println(reading4); print(“BIAS: “); println(reading5); print(readingEnough1); print(” : “); print(readingEnough2); print(” : “); print(readingEnough3); print(” : “); println(readingEnough4); readAll = readingEnough1 + readingEnough2 + readingEnough3 + readingEnough4; //count to see if every photocell has received a bright light print(“readAll : “); println(readAll); delay(50); if (readAll >= 12) { ringBuzzerLight(); } } void ringBuzzerLight() { int threshold = 5; println(“You hit all Photocells”); for (int r = 0; r <=5; r++) { println(r); if (r == threshold){ digitalWrite(ringerlight,LOW); readingEnough1 = 0; readingEnough2 = 0; readingEnough3 = 0; readingEnough4 = 0; break; } digitalWrite(ringerlight, HIGH); delay(500); digitalWrite(ringerlight,LOW); delay(500); } }int reading3 = analogRead(lightPin3); if (reading3 > (150+bias)) readingEnough3 = readingEnough3 + 1; delay(20); int reading4 = analogRead(lightPin4); if (reading4 > (150+bias)) readingEnough4 = readingEnough4 + 1; delay(20); print(reading); Serial.print(” : “); Serial.print(reading2); Serial.print(” : “); Serial.print(reading3); Serial.print(” : “); Serial. println(reading4); Serial.print(“BIAS: “); Serial. println(reading5); Serial.print(readingEnough1); Serial.print(” : “); Serial.print(readingEnough2); Serial.print(” : “); Serial.print(readingEnough3); Serial.print(” : “); Serial. println(readingEnough4); readAll = readingEnough1 + readingEnough2 + readingEnough3 + readingEnough4; //count to see if every photocell has received a bright light Serial.print(“readAll : “); Serial. println(readAll); delay(50); if (readAll >= 12) { ringBuzzerLight(); } } void ringBuzzerLight() { int threshold = 5; Serial.println(“You hit all Photocells”); for (int r = 0; r <=5; r++) { Serial.println(r); if (r == threshold){ digitalWrite(ringerlight,LOW); readingEnough1 = 0; readingEnough2 = 0; readingEnough3 = 0; readingEnough4 = 0; break; } digitalWrite(ringerlight, HIGH); delay(500); digitalWrite(ringerlight,LOW); delay(500); } }

See also  【 Export Telegram Conversations 】 Step by Step Guide ▷ 2022
Loading Facebook Comments ...
Loading Disqus Comments ...