Today we are going to talk about Rain Sensor Module.
There are sensors or sensors that can detect when rain or rainfalls. These are called Rain Sensor Module. Using the data available to this sensor, you can write various programs to create various devices that are useful in everyday life.
There are 2 parts to this module. One is called the module itself (Figure 2). The other part is called the collector (Figure 3). Water should fall on this collector.
There is 2 pin on one side of the Rane Sensor module. The two-pin connects to the collector on the ray sensor. One of these is called the GND Pin. The other side of the module is 4 pin. Near the pin 4 are encrypted letters that identify them. The functions of the pin are:
A0: - Analog output via the module to the analog board.
D0: - The digital output to the input board through the module.
GND: - This is used as the underground end which can provide a (-) connection to the module.
VCC: - This pin can be used to supply 5V power to the module.
There are two LED bulbs on this module. One of the modules will light up when it receives electricity. The other bulb lights up when output is received through the module. There is a Sensitive Adjustment on the module. This can be done by rotating the module's sensitivity to rain.
const int capteur_D = 4;
const int capteur_A = A0;
int val_analogique;
void setup ()
{
pinMode (capteur_D, INPUT);
pinMode (capteur_A, INPUT);
Serial.begin (9600);
}
void loop ()
{
if (digitalRead (capteur_D) == LOW)
{
Serial.println ("Digital value: wet");
delay (10);
}
else
{
Serial.println ("Digital value: dry");
delay (10);
}
val_analogique = analogRead (capteur_A);
Serial.print ("Analog value:");
Serial.println (val_analogique);
Serial.println ( "");
delay (1000);
}
To check the output, go to Tools> Serial Monitor from the menu bar in the Governance Project window. This will open the window corresponding to the Cereal Monitor. Now you can see Raining ?: NO and the LED bulb does not flash. Now sprinkle a little water on the collector of the Rain Sensor module. You can then see Raining ?: YES on the Cereal Monitor and the LED will light up.
Here, the first 6 lines are arranged in a variable 6. The first, second, and fourth lines are written to identify the analog pin A5, the digital pin 2, and the LED pin 5.
Line 7 begins with the void setup section. The 3 rows under it run once when the program starts. Row 8 is written to use the Cereal Monitor. Line 9 is written to get the 2 pin input. Row 10 has turned the 5th Pin into an Output.
If the waterfalls into the collector, line 14 checks for that and inserts YES into the straining variable.
The code written inline 21 is shown in Raining Monitor on Cereal Monitor. Row 22 here returns the value added to the straining variable, either YES or NO. The 16th row of the Cereal Monitor YES code is written to illuminate the LED. Line 19 has code to turn off the LED bulb in the absence of rain.
So let me tell you one thing that many of us who have heard about the comments and the inbox hasn't heard of is the Arduino Parts. So I thought if I told you where to buy it, it would be easy for you.
0 Comments