Please add these two Urgent
First
const int VAL_PROBE = 0; //Analog pin 0
const int MOISTURE_LEVEL = 450; // the value after the LED goes on
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(7, OUTPUT);
}
void LedState(int state)
{
digitalWrite(7,state);
}
void loop()
{
int moisture = analogRead(VAL_PROBE);
Serial.print("Moisture = ");
Serial.println(moisture);
if(moisture > MOISTURE_LEVEL)
{
LedState(HIGH);
digitalWrite(13,LOW);
}
else
{
LedState(LOW);
digitalWrite(13,HIGH);
}
delay(500);
}
Second
#include <LiquidCrystal.h>
LiquidCrystal LCD(10, 9, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
pinMode(A0, INPUT);
LCD.begin(16,2);
}
void loop()
{
int SensorValue= analogRead(A0);
Serial.print(SensorValue);
Serial.print(" - ");
if(SensorValue >= 1000)
{
Serial.println("not in Soil or DISCONNECTED");
LCD.setCursor(0,0);
LCD.print("NOT IN SOIL");
LCD.print(" ");
}
if(SensorValue < 1000 && SensorValue >= 600)
{
Serial.println("DRY");
LCD.setCursor(0,0);
LCD.print("DRY");
LCD.print(" ");
}
if(SensorValue < 600 && SensorValue >= 370)
{
Serial.println("HUMID");
LCD.setCursor(0,0);
LCD.print("HUMID");
LCD.print(" ");
}
if(SensorValue < 370)
{
Serial.println("WATER");
LCD.setCursor(0,0);
LCD.print("WATER");
LCD.print(" ");
}
LCD.setCursor(0,1);
LCD.print(" ");
LCD.setCursor(0,1);
LCD.print(SensorValue);
delay(1000);
}