Code:
#include<LiquidCrystal.h>
LiquidCrystallcd (4,5,6,7,8,9);
#include<Software Serial .h>
Software Serial gsm(2,3); //TX,RX
#define led pin 11
#define motor pin 10
Int sensor pin = A0;
int sensor value;
void setup()
{
Lcd .begin(16,2);
gsm .begin(9600);
Serial .begin(9600);
Pin Mode (led pin, OUTPUT);
Pin Mode (motor pin, OUTPUT);
Pin Mode (sensor pin, INPUT);
lcd.print ("BAPATLA POLYTECHNIC");
Delay (5000);
lcd.set Cursor (0,0);
lcd. Println ("AUTOMATIC IRRIGATION SYSTEM");
delay (5000);
lcd .clear ();
lcd.println("SYSTEM READY");
delay(5000);
}
void loop()
{
Lcd .clear();
lcd.setCursor(0,0);
lcd.println("AUTOMATIC MODE");
delay(1000);
sensor_value = analogRead(sensor_pin);
sensor_value = map(sensor_value,550,0,0,100);
if(sensor_value< 10)
{
digitalWrite(led_pin, HIGH);
digitalWrite(motor_pin, HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.println("Motor ON ");
delay(1000);
//lcd.print("Sending SMS");
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CMGS=\"+919121957508\"\r"); //replace x by your
number
delay(1000);
gsm.print("Low Soil Moisture detected. Motor turned ON");
delay(1000);
gsm.println((char)26);
delay(1000);
}
if(sensor_value> 10)
{
digitalWrite(led_pin, LOW);
digitalWrite(motor_pin, LOW);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Motor OFF");
delay(1000);
//lcd.print("Sending SMS");
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CMGS=\"+919121957508\"\r"); //replace x by your
number
delay(1000);
gsm.print("Soil Moisture normal. Motor turned OFF");
delay(1000);
gsm.println((char)26);
delay(1000);
}
}
Comments