Interface Soil Moisture Sensor to Arduino

Soil Moisture Sensor Connection with Arduino





code

const int VAL_PROBE = 0; // Analog pin 0
const int MOISTURE_LEVEL = 900; /* the value after the LED goes ON */
void setup() {
Serial.begin(9600);
}
void LedState(int state) {
digitalWrite(12, state);
}
void loop() {
int moisture = analogRead(VAL_PROBE);
Serial.println(moisture);
if(moisture > MOISTURE_LEVEL) {
LedState(LOW);
} else {
LedState(HIGH);
}
delay(400);
}