int moist_pin = A0;
int moist_value;
int outvalue;
#include <LiquidCrystal.h>
const int rs =12 , en =11 , d4 = 4 , d5 = 5, d6 = 6,d7 =7;
LiquidCrystal lcd (rs ,en, d4,d5,d6,d7);
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("welcome to");
lcd.setCursor(0,1);
lcd.print("the project");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Made by");
lcd.setCursor(0,1);
lcd.print("Yash Kadam");
delay(1000);
lcd.clear();
pinMode(3, OUTPUT);
// put your setup code here, to run once:
}
void loop() {
moist_value = analogRead(A0);
outvalue=moist_value/4;
//analogWrite(3,outvalue);
//analogwrite(3,moist_value);
Serial.println(moist_value);
moist_value = map(moist_value,10.2,1023,0,100);
outvalue = map(outvalue,0,255,255,0);
analogWrite(3,outvalue);
Serial.print("moisture: ");
Serial.print(moist_value);
lcd.setCursor(0,0);
lcd.print("Moisture : ");
lcd.print(moist_value);
lcd.print("%");
delay(500);
lcd.clear();
if(moist_value<30)
{
lcd.setCursor(0,1);
lcd.print("Moisture LOw");
Serial.print("low");
}
else if(moist_value<74)
{ lcd.setCursor(0,1);
lcd.print("MOisture Mid");
Serial.print("mid");
}
else if(moist_value>75)
{
lcd.setCursor(0,1);
Serial.print("High");
lcd.print("moisture High");
}
// put your main code here, to run repeatedly:
}