Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Last active May 10, 2018 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arduinothai/a18ff133a7f6e646c104989898b7ae91 to your computer and use it in GitHub Desktop.
Save arduinothai/a18ff133a7f6e646c104989898b7ae91 to your computer and use it in GitHub Desktop.
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