7
void setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
delay(1000);
Serial.print("sensor = " );
Serial.println(sensorValue);
}
Upload the code, please click
if you do not know how to upload.
The Result in different condition after open the serial monitor:
Sensor in air
Sensor in dry soil
Sensor in humid soil
Sensor in water
With TI LaunchPad
Taking care of your plants (Moisture Sensor)
The following sketch demonstrates a simple application of sensing the moisture in soil. With this,
you can know whether your plant needs water or not by observing the results from the output of
the sensor.