Last active
May 10, 2018 12:56
-
-
Save arduinothai/a18ff133a7f6e646c104989898b7ae91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sensorPin = A0; // select the input pin for the Soil moisture sensor | |
int sensorValue = 0; // variable to store the value coming from the sensor | |
void setup() { | |
// declare the ledPin as an OUTPUT: | |
Serial.begin(9600); | |
} | |
void loop() { | |
// read the value from the sensor: | |
sensorValue = analogRead(sensorPin); | |
delay(500); | |
Serial.print("sensor = " ); | |
Serial.println(sensorValue); | |
if(sensorValue <= 300) | |
{ | |
Serial.println("Dry Soil"); | |
} | |
else if(sensorValue > 300 && sensorValue <= 700) | |
{ | |
Serial.println("Humid Soil"); | |
} | |
else | |
{ | |
Serial.println("in Water"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment