Your repairman.  Finishing work, exterior, preparatory

Not all owners of gardens and orchards have the opportunity to take care of their plantings every day. Nevertheless, without timely watering, one cannot count on a good harvest.

The solution to the problem will be an automatic system that allows you to ensure that the soil in your area maintains the required degree of moisture throughout your absence. The main component of any automatic watering is the soil moisture sensor.

The concept of a humidity sensor

The humidity sensor also has other names. It is called a moisture meter or humidity sensor.


As can be seen in the photo of soil moisture sensors, such a device is a device consisting of two wires connected to a weak source of electricity.

With an increase in humidity between the electrodes, the current strength and resistance decrease, and vice versa, if there is not enough water in the soil, these indicators increase. The device turns on with a simple push of a button.

Keep in mind that the electrodes will be in moist soil. Therefore, it is recommended to turn on the device through the key. This technique will reduce the negative effects of corrosion.

Why is this device needed?

Moisture meters are installed not only on open ground, but also in greenhouses. Controlling watering times is what soil moisture sensors are used for. You do not need to do anything, just turn on the device. After that, it will work without your participation.

However, gardeners and gardeners should monitor the condition of the electrodes, as they can undergo corrosive destruction and fail as a result.

Types of soil moisture sensors

Consider what soil moisture sensors are. They are usually divided into:

Capacitive. Their design is similar to an air condenser. The work is based on a change in the dielectric properties of air depending on its humidity, which causes an increase or decrease in capacity.

Resistive. The principle of their operation is to change the resistance of a hygroscopic material, depending on how much moisture it contains.

Psychometric. The principle of operation and the scheme of the device of such sensors will be more complicated. It is based on the physical property of heat loss during evaporation. The instrument consists of a dry and a wet detector. The temperature difference between them is used to judge the amount of water vapor in the air.

Aspiration. This type is in many ways similar to the previous one, the difference is the fan, which serves to pump the air mixture. Aspiration devices for determining humidity are used in places with weak or intermittent air movement.

Which humidity sensor to choose depends on each specific case. The choice of device is also influenced by the features of the automatic irrigation system you have installed and your financial capabilities.


Materials needed to create a sensor with your own hands

If you decide to start making a moisture meter yourself, then you need to prepare:

  • electrodes with a diameter of 3-4 mm - 2 pcs.;
  • textolite base;
  • nuts and washers.

Manufacturing instructions

How to make a soil moisture sensor with your own hands? Here is a brief tutorial:

  • Step 1. Attach the electrodes to the base.
  • Step 2. We cut the threads at the ends of the electrodes and sharpen them on the reverse side for easier immersion in the soil.
  • Step.3. We make holes in the base and screw the electrodes into them. We use nuts and washers as fasteners.
  • Step 4. We select the necessary wires that fit the washers.
  • Step 5. Isolate the electrodes. We deepen them into the ground by 5 - 10 cm.

Note!

For the sensor to work, a current of 35 mA and a voltage of 5 V are required. At the end, we connect the device using three wires, which we attach to the microprocessor.

The controller allows you to combine a sensor with a buzzer. After that, a signal is given if the amount of moisture in the soil decreases sharply. An alternative to a sound signal can be a light bulb.

The soil moisture sensor is, without a doubt, a necessary thing in the household. If you have a cottage or garden, then by all means take care of acquiring it. Moreover, the device is not at all necessary to buy, since you can easily do it yourself.

Photo of soil moisture sensors

Note!

Note!

LED turns on when plants need to be watered
Very low current consumption from 3V battery

Schematic diagram:

List of components:

Resistors 470 kOhm ¼ W

Cermet or carbon
trimmer resistor 47 kOhm ½ W

Resistor 100 kOhm ¼ W

Resistor 3.3 kOhm ¼ W

Resistor 15 kOhm ¼ W

Resistor 100 Ohm ¼ W

Mylar Capacitor 1nF 63V

Mylar Capacitor 330nF 63V

Electrolytic Capacitors 10uF 25V

Red LED with a diameter of 5 mm

Electrodes (See notes)

3 V battery (2 AA, N or AAA batteries,
connected in series)

Purpose of the device:

The circuit is designed to give a signal if the plants need watering. The LED starts flashing if the soil in the flower pot is too dry and goes out when the humidity increases. The trimmer resistor R2 allows you to adapt the sensitivity of the circuit to various types of soil, flower pot sizes and types of electrodes.

Circuit development:

This little device has been a big hit with electronic hobbyists over the years since 1999. However, as I have corresponded with many hams over the years, I have come to realize that some criticisms and suggestions need to be taken into account. The circuit has been improved by adding four resistors, two capacitors and one transistor. As a result, the device has become easier to set up and more stable in operation, and the brightness of the glow has been increased without using super-bright LEDs.
Many experiments have been carried out with various flower pots and various sensors. And although, as it is easy to imagine, flower pots and electrodes were very different from each other, the resistance between two electrodes immersed in the soil by 60 mm at a distance of about 50 mm was always in the range of 500 ... 1000 Ohms with dry soil, and 3000 ... 5000 ohms wet

Circuit operation:

Chip IC1A and its associated R1 and C1 form a square-wave generator with a frequency of 2 kHz. Through an adjustable divider R2 / R3, the pulses are fed to the input of the gate IC1B. When the resistance between the electrodes is low (i.e., if there is enough moisture in the flower pot), capacitor C2 shunts the input of IC1B to ground, and a high voltage level is constantly present at the output of IC1B. Gate IC1C inverts the output of IC1B. Thus, the input of IC1D is blocked low, and the LED is accordingly turned off.
When the soil in the pot dries out, the resistance between the electrodes increases, and C2 ceases to interfere with the flow of pulses to the input of IC1B. After passing through IC1C, the 2 kHz pulses enter the blocking input of the oscillator assembled on the IC1D chip and its surrounding components. IC1D starts to generate short pulses, turning on the LED via transistor Q1. LED flashes indicate the need to water the plant.
The base of transistor Q1 is fed with rare bursts of short negative pulses with a frequency of 2 kHz, cut out from the input pulses. Consequently, the LED flashes 2000 times per second, but the human eye perceives such frequent flashes as a constant glow.

Notes:

  • To prevent oxidation of the electrodes, they are powered by rectangular pulses.
  • The electrodes are made from two pieces of stripped single-core wire, 1 mm in diameter and 60 mm long. You can use the wire used for wiring.
  • The electrodes must be completely immersed in the ground at a distance of 30 ... 50 mm from each other. The material of the electrodes, the dimensions and the distance between them, in general, do not matter much.
  • The current consumption of about 150 µA when the LED is off, and 3 mA when the LED is on for 0.1 second every 2 seconds, allows the device to work for years on a single set of batteries.
  • With such a small current consumption, there is simply no need for a power switch. If, nevertheless, there is a desire to turn off the circuit, it is enough to short-circuit the electrodes.
  • 2 kHz from the output of the first generator can be checked without a probe or oscilloscope. You can simply hear them if you connect the P2 electrode to the input of a low-frequency amplifier with a speaker, and if you have an ancient high-impedance earphone TON-2, then you can do without an amplifier.
  • The circuit is assembled clearly according to the manual and working 100%!!! ...so if suddenly "DOES NOT work", then it's just the wrong assembly or parts. To be honest, until recently I did not believe that it was "working".
  • Question for the experts!!! How can you fit a 12V constant pump with a consumption of 0.6A and a starting 1.4A as an actuating device?!
  • Sobos WHERE to fit? What to manage? .... Formulate the question CLEARLY.
  • In this circuit (full description http://www..html?di=59789), the indicator of its operation is an LED that lights up when the ground is "dry". There is a great desire to automatically turn on the irrigation pump (12V constant with a consumption of 0.6A and a starting 1.4A) along with the inclusion of this LED, how to change or "finish" the circuit in order to implement this.
  • ...maybe someone has any thoughts?!
  • Install an opto-relay or an opto-triac instead of the LED. The dose of water can be adjusted by a timer or by the location of the sensor/irrigation point.
  • It's strange, I assembled the circuit and it works fine, but only the LED "if watering is needed" fully flickers at a frequency of approximately 2 kHz, and does not burn constantly, as some forum users say. Which in turn provides savings when using batteries. It is also important that with such a low power supply, the electrodes in the ground undergo little corrosion, especially the anode. And one more thing, at a certain level of humidity, the LED starts to barely glow and this can continue for a long time, which did not allow me to use this circuit to turn on the pump. I think that in order to reliably turn on the pump, some kind of determinant of pulses of a specified frequency coming from this circuit and giving a "command" to control the load is needed. I ask SPECIALISTS to suggest a scheme for the implementation of such a device. I want to implement automatic watering in the country on the basis of this scheme.
  • A very promising scheme in its "economy" that needs to be finalized and used in garden plots or, for example, at work, which is very important when it's a weekend or vacation, as well as at home for automatic watering of flowers.
  • has always been within 500…1000 ohms with dry soil, and 3000…5000 ohms with wet soil - in the sense - on the contrary!!??
  • I'll wash this bullshit. Over time, salts are deposited on the electrodes and the system does not work on time. A couple of years ago I did this, I only did it on two transistors according to the scheme from the MK magazine. Enough for a week, and then shifted. The pump worked and did not turn off, filling the flower. I met circuits on alternating current on the network, so I think they should be tried.
  • Good day!!! As for me, any idea to create something is already good. - As for the installation of the system in the country - I would advise you to turn on the pump through a time relay (it costs a penny in many electrical equipment stores) set it to turn off after a time from turning on. Thus, when your system jams (well, anything can happen), the pump will turn off after a time that is guaranteed to be sufficient for irrigation (select it empirically). - http://tuxgraphics.org/electronics/201006/automatic-flower-watering-II.shtml Here's a good thing, I didn't build this circuit specifically, I used only an Internet connection. A little glitchy (not the fact that my handles are very straight), but everything works.
  • I collected schemes for watering but not for this one which is discussed in this thread. The assembled ones work one, as mentioned above, in terms of the time the pump is turned on, the other, which is very promising in terms of the level in the sump where water is pumped directly into the sump. For plants, this is the best option. But the essence of the question is to adapt the specified scheme. Only due to the fact that the anode in the ground is almost not destroyed as in the implementation of other schemes. So, I ask you to tell me how to track the pulse frequency in order to turn on the actuator. The problem is further aggravated by the fact that the LED can "smolder" for a barely certain time, and then only turn on in the pulsed mode.
  • The answer to the question asked earlier, on finalizing the soil moisture control scheme, was received on another forum and tested for 100% performance :) If anyone is interested, write in a personal.
  • Why such confidentiality and not immediately indicate a link to the forum. Here, for example, on this forum http://forum.homecitrus.ru/index.php?showtopic=8535&st=100 the problem is practically solved on the MK, but on the logic it was solved and tested by me. Only in order to understand it is necessary to read from the beginning of the "book", and not from the end. I am writing this in advance for those who read a piece of text and begin to fill up with questions. :eek:
  • The link http://radiokot.ru/forum/viewtopic.php?f=1&t=63260 was not immediately given due to the fact that it would not be considered as an advertisement.
  • for [B]Vell65
  • http://oldoctober.com/en/automatic_watering/#5
  • This is a stage already passed. The problem is solved by another scheme. As information. The lower improved circuit has errors, the resistances are burning. Printing on the same site was completed without errors. When testing the circuit, the following shortcomings were identified: 1. It turns on only once a day, when the tomatoes have already withered, and it is better to keep silent about cucumbers altogether. And just when the sun was hot, they needed [B] drip irrigation under the root, because plants in extreme heat evaporate a large amount of moisture, especially cucumbers. 2. There is no protection against false activation when, for example, at night the photocell is illuminated by headlights or lightning and the pump is activated when the plants are sleeping and they do not need watering, and nightly turning on the pump does not contribute to a healthy sleep of the household.
  • We remove the photo sensor, see the first version of the circuit where it is absent, we select the elements of the temporary circuit of the pulse generator as you wish. I have R1 \u003d 3.9 Mom. R8 which is 22m no. R7=5.1 Mom. Then the pump turns on when the soil is dry, for a while until the sensor gets wet. I took the device as an example of an automatic watering machine. Many thanks to the author.
Arduino Soil Moisture Sensor designed to determine the moisture content of the ground in which it is immersed. It lets you know if your house or garden plants are under or over watered. Connecting this module to the controller allows you to automate the process of watering your plants, vegetable garden or plantation (a kind of "smart watering").

The module consists of two parts: contact probe YL-69 and sensor YL-38, wires for connection are included. A small voltage is created between the two electrodes of the YL-69 probe. If the soil is dry, the resistance is high and the current will be less. If the ground is wet, the resistance is less, the current is slightly more. According to the final analog signal, one can judge the degree of humidity. The YL-69 probe is connected to the YL-38 probe via two wires. In addition to the pins for connecting to the probe, the YL-38 sensor has four pins for connecting to the controller.

  • Vcc – sensor power supply;
  • GND - ground;
  • A0 - analog value;
  • D0 is the digital value of the humidity level.
The YL-38 sensor is built on the basis of the LM393 comparator, which supplies voltage to the D0 output according to the principle: wet soil - low logic level, dry soil - high logic level. The level is determined by a threshold value that can be adjusted with a potentiometer. An analog value is applied to the A0 pin, which can be transferred to the controller for further processing, analysis and decision making. The YL-38 sensor has two LEDs that signal the presence of a power supply coming to the sensor and a digital signal level at the D0 output. The presence of a digital output D0 and a level LED D0 allows you to use the module autonomously, without connecting to the controller.

Module Specifications

  • Supply voltage: 3.3-5 V;
  • Current consumption 35 mA;
  • Output: digital and analog;
  • Module size: 16×30 mm;
  • Probe size: 20×60 mm;
  • Total weight: 7.5g

Usage example

Consider connecting a soil moisture sensor to an Arduino. Let's create a soil moisture indicator project for a houseplant (your favorite flower that you sometimes forget to water). To indicate the level of soil moisture, we will use 8 LEDs. For the project, we need the following details:
  • Arduino Uno Board
  • Soil moisture sensor
  • 8 LEDs
  • Bread board
  • Connecting wires.
We will assemble the circuit shown in the figure below


Let's start the Arduino IDE. Let's create a new sketch and add the following lines to it: // Soil moisture sensor // http: // site // contact for connecting the analog output of the sensor int aPin=A0; // pins for connecting indication LEDs int ledPins=(4,5,6,7,8,9,10,11); // variable for storing the sensor value int avalue=0; // variable number of glowing LEDs int countled=8; // full watering value int minvalue=220; // critical dryness value int maxvalue=600; void setup() ( // initialization of the serial port Serial.begin(9600); // setting the LED indication pins // to OUTPUT mode for(int i=0;i<8;i++) { pinMode(ledPins[i],OUTPUT); } } void loop() { // получение значения с аналогового вывода датчика avalue=analogRead(aPin); // вывод значения в монитор последовательного порта Arduino Serial.print("avalue=");Serial.println(avalue); // scale the value by 8 LEDs countled=map(avalue,maxvalue,minvalue,0,7); // humidity level indication for(int i=0;i<8;i++) ( if(i<=countled) digitalWrite(ledPins[i],HIGH); //light the LED else digitalWrite(ledPins[i],LOW) ; // turn off the LED ) // pause before the next value is received 1000 ms delay(1000); ) The analog output of the sensor is connected to the analog input of the Arduino, which is an analog-to-digital converter (ADC) with a resolution of 10 bits, which allows the output to receive values ​​\u200b\u200bfrom 0 to 1023. ) will be obtained experimentally. Greater dryness of the soil corresponds to a greater value of the analog signal. Using the map function, we scale the analog value of the sensor to the value of our LED indicator. The greater the soil moisture, the greater the value of the LED indicator (number of LEDs lit). By connecting this indicator to a flower, we can see the degree of humidity on the indicator from afar and determine the need for watering.

(!LANG:FAQ

1. Power LED is off
  • Check the presence and polarity of the power supplied to the YL-38 sensor (3.3 - 5 V).
2. When watering the soil, the soil moisture indicator LED does not light up
  • Set the threshold with the potentiometer. Check the connection of the YL-38 probe to the YL-69 probe.
3. When watering the soil, the value of the output analog signal does not change
  • Check the connection of the YL-38 probe to the YL-69 probe.
  • Check if the probe is in the ground.

I wrote a lot of reviews about dacha automation, and since we are talking about a dacha, then automatic watering is one of the priority areas of automation. At the same time, you always want to take into account precipitation so as not to drive pumps in vain and not to flood the beds. Many copies have been broken on the path to trouble-free soil moisture data acquisition. In the review, there is another option that is resistant to external influences.


A pair of sensors arrived in 20 days in individual antistatic bags:




Characteristics on the seller's website:):
Brand:ZHIPU
Type: Vibration sensor
Material: Blend
Output: Switching sensor

Unpacking:


The wire has a length of around 1 meter:


In addition to the sensor itself, the kit includes a control board:




The length of the sensors of the sensor is about 4 cm:


The tips of the sensor, it looks like graphite - get dirty black.
We solder the contacts to the scarf and try to connect the sensor:




The most common soil moisture sensor in Chinese stores is this one:


Many people know that after a short time it is eaten by the external environment. The effect of corrosion can be slightly reduced by applying power immediately before the measurement and turning it off when no measurements are made. But this does not change much, this is what mine looked like after a couple of months of use:




Someone tries to use thick copper wire or stainless steel rods, an alternative designed specifically for aggressive environments is the subject of review.

Let's put the board from the kit aside, and deal with the sensor itself. Resistive type sensor, changes its resistance depending on the humidity of the environment. It is logical that without a humid environment, the resistance of the sensor is huge:


We lower the sensor into a glass of water and see that its resistance will be about 160 kOhm:


If you take it out, everything will return to its original state:


Let's move on to the tests on the ground. In dry soil we see the following:


Let's add some water:


More (about a litre):


Almost completely poured one and a half liters:


Added another liter and waited 5 minutes:

The board has 4 pins:
1 + supply
2 earth
3 digital output
4 analog output
After ringing, it turned out that the analog output and ground are directly connected to the sensor, so if you plan to use this sensor by connecting it to an analog input, the board does not make much sense. If there is no desire to use the controller, then you can use the digital output, the threshold is set by the potentiometer on the board. Seller's recommended wiring diagram when using digital output:


When using a digital input:


Let's put together a small layout:


I used the Arduino Nano here as a power source without downloading the program. Digital output connected to the LED. It's funny that the red and green LEDs on the board are lit at any position of the potentiometer and the humidity of the sensor environment, the only thing when the threshold is triggered, the green shines a little weaker:


Having set the threshold, we get that when the specified humidity is reached at the digital output 0, when the humidity is deficient, the supply voltage is:




Well, since we have a controller in our hands, we will write a program to check the operation of the analog output. Connect the analog output of the sensor to pin A1, and the LED to pin D9 of the Arduino Nano.
const int analogInPin = A1; // sensor const int analogOutPin = 9; // Output to LED int sensorValue = 0; // read value from the sensor int outputValue = 0; // value given to the PWM pin with LED void setup() ( Serial.begin(9600); ) void loop() ( // read the sensor value sensorValue = analogRead(analogInPin); // translate the range of possible sensor values ​​(400-1023 - set experimentally) // to the PWM output range 0-255 outputValue = map(sensorValue, 400, 1023, 0, 255); // turn on the LED for a given brightness analogWrite(analogOutPin, outputValue); // output our numbers Serial.print ("sensor = "); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); // delay delay(2); )
I commented all the code, the brightness of the LED is inversely proportional to the humidity detected by the sensor. If it is necessary to control something, then it is enough to compare the obtained value with an experimentally determined threshold and, for example, turn on the relay. The only thing I recommend is to process several values ​​and use the average to compare with the threshold, so random spikes or drops are possible.
We immerse the sensor and see:


Controller output:

If you take it out, the output of the controller will change:

Video of this test build:

In general, I liked the sensor, it gives the impression of being resistant to the influence of the external environment, whether this is so - time will tell.
This sensor cannot be used as an accurate indicator of humidity (as well as all similar ones), its main application is to determine the threshold and analyze the dynamics.

If it is interesting, I will continue to write about my country crafts.
Thanks to everyone who read this review to the end, I hope this information will be useful to someone. All complete control over soil moisture and goodness!

I plan to buy +74 Add to favorites Liked the review +55 +99

Connect the Arduino to the FC-28 Soil Moisture Sensor to determine when your soil under your plants needs water.

In this article, we are going to use the FC-28 Soil Moisture Sensor with Arduino. This sensor measures the volumetric water content of the soil and gives us the moisture level. The sensor gives us analog and digital data at the output. We are going to connect it in both modes.

The soil moisture sensor consists of two sensors that are used to measure the volumetric water content. The two probes allow the current to pass through the soil, which gives a resistance value, which finally measures the moisture value.

When there is water, the soil will conduct more electricity, which means there will be less resistance. Dry soil is a poor conductor of electricity, so when there is less water, the soil conducts less electricity, which means more resistance.

The FC-28 sensor can be connected in analog and digital modes. We will connect it first in analog mode and then in digital mode.

Specification

FC-28 Soil Moisture Sensor Specifications:

  • input voltage: 3.3–5V
  • output voltage: 0–4.2V
  • input current: 35mA
  • output signal: analog and digital

Pinout

Soil moisture sensor FC-28 has four pins:

  • VCC: Power
  • A0: analog output
  • D0: digital output
  • GND: ground

The module also contains a potentiometer that will set the threshold value. This threshold value will be compared on the LM393 comparator. The LED will signal us the value above or below the threshold.

Analog mode

To connect the sensor in analog mode, we need to use the analog output of the sensor. Soil moisture sensor FC-28 accepts analog output values ​​from 0 to 1023.

Humidity is measured as a percentage, so we will compare these values ​​from 0 to 100 and then display them on the serial monitor. You can set different moisture values ​​and turn the water pump on/off according to these values.

Wiring diagram

Connect the soil moisture sensor FC-28 to the Arduino as follows:

  • VCC FC-28 → 5V Arduino
  • GND FC-28 → GND Arduino
  • A0 FC-28 → A0 Arduino

Code for analog output

For the analog output, we write the following code:

int sensor_pin = A0; int output_value ; void setup() ( Serial.begin(9600); Serial.println("Reading From the Sensor ..."); delay(2000); ) void loop() ( output_value= analogRead(sensor_pin); output_value = map(output_value ,550,0,0,100); Serial.print("Mositure: "); Serial.print(output_value); Serial.println("%"); delay(1000); )

Code Explanation

First of all, we defined two variables, one for the contact of the soil moisture sensor and the other for storing the output of the sensor.

int sensor_pin = A0; int output_value ;

In the setup function, the command Serial.begin(9600) will help in communication between Arduino and serial monitor. After that, we will print “Reading From the Sensor ...” on the normal display.

Void setup() ( Serial.begin(9600); Serial.println("Reading From the Sensor ..."); delay(2000); )

In the loop function, we will read the value from the analog output of the sensor and store the value in a variable output_value. Then we will compare the output values ​​from 0-100 because humidity is measured in percentage. When we took readings from dry soil, the sensor value was 550, and in wet soil, the sensor value was 10. We compared these values ​​to get the moisture value. After that, we printed these values ​​on the serial monitor.

void loop() ( output_value= analogRead(sensor_pin); output_value = map(output_value,550,10,0,100); Serial.print("Mositure: "); Serial.print(output_value); Serial.println("%") ;delay(1000); )

Digital mode

To connect the FC-28 soil moisture sensor in digital mode, we will connect the sensor's digital output to an Arduino digital pin.

The sensor module contains a potentiometer which is used to set the threshold value. The threshold value is then compared with the sensor output value using the LM393 comparator, which is placed on the FC-28 sensor module. The LM393 comparator compares the output value of the sensor and the threshold value, and then gives us the output value through a digital output.

When the sensor value is greater than the threshold value, the digital output will give us 5V and the sensor LED will light up. Otherwise, when the sensor value is less than this threshold value, 0V will be transmitted to the digital output and the LED will not light up.

Wiring diagram

The connections for the soil moisture sensor FC-28 and Arduino in digital mode are as follows:

  • VCC FC-28 → 5V Arduino
  • GND FC-28 → GND Arduino
  • D0 FC-28 → Pin 12 Arduino
  • LED positive → Pin 13 Arduino
  • LED minus → GND Arduino

Code for digital mode

The code for digital mode is below:

intled_pin=13; int sensor_pin=8; void setup() ( pinMode(led_pin, OUTPUT); pinMode(sensor_pin, INPUT); ) void loop() ( if(digitalRead(sensor_pin) == HIGH)( digitalWrite(led_pin, HIGH); ) else ( digitalWrite(led_pin, LOW); delay(1000); ) )

Code Explanation

First of all, we initialized 2 variables to connect the LED output and the digital output of the sensor.

int led_pin = 13; int sensor_pin = 8;

In the setup function, we declare the LED pin as an output pin, because we will turn on the LED through it. We declared the sensor pin as an input pin, because the Arduino will receive values ​​from the sensor through this pin.

Void setup() ( pinMode(led_pin, OUTPUT); pinMode(sensor_pin, INPUT); )

In the loop function, we read from the output of the sensor. If the value is higher than the threshold value, then the LED will turn on. If the sensor value is below the threshold value, the indicator will turn off.

Void loop() ( if(digitalRead(sensor_pin) == HIGH)( digitalWrite(led_pin, HIGH); ) else ( digitalWrite(led_pin, LOW); delay(1000); ) )

This concludes the introductory lesson on working with the FC-28 sensor for Arduino. Good luck with your projects.

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE:
Your repairman.  Finishing work, exterior, preparatory