Description
Guys, In this project we are going to monitor the value of rain and moisture level in the serial monitor of Arduino software using Rain Sensor. Okay, let's make it.
Components Required
1. | Arduino UNO | * 1 |
2. | Rain Sensor | * 1 |
3. | Jumper Wires | * 1 |
Circuit Diagram
Program
int nRainVal;
boolean bIsRaining = false;
String strRaining;
void setup()
{
Serial.begin(9600);pinMode(2,INPUT);
}
void loop()
{nRainVal = analogRead(A1);
bIsRaining = !(digitalRead(nRainDigitalIn)); //Cheks Digital Pin 2, Output D0
if(bIsRaining)
{
//Cheks Digital Pin 2, Output D0
strRaining = "YES";}
else
{strRaining = "NO";
}
Serial.print("Raining: ");
Serial.print(strRaining);
Serial.print(" Moisture Level: ");
Serial.println(nRainVal);
delay(1000);
}