'Serial1' was not declared in this scope for automatic plant watering #include &lt;LiquidCrystal.h&gt;
#include &lt;SoftwareSerial.h&gt;
int in1 = 2;
int in2 = 3;
LiquidCrystal lcd(14,15,16,17,18,19);
int led = 13;
int flag = 0;
int motorpin = 11;
int sensorpin = 7;

void setup()
{
  lcd.begin(16,2);
  Serial1.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(motor, OUTPUT);
  pinMode(sensor, INPUT_PULLUP);
  lcd.print(&quot;Plant Watering&quot;);
  lcd.setCursor(4,1);
  delay(2000);
  lcd.clear()
  lcd.print(&quot;RCC INSTITUTE&quot;);
  lcd.setCursor(0,1);
  lcd.print(&quot;Starting....&quot;);
  delay(2000);
  gsmInit();
  lcd.clear();
  lcd.print(&quot;System Ready&quot;);
}

void loop()
{
  lcd.setCursor(0,0);
  lcd.print(&quot;Automatic Mode&quot;);
  if (digitalRead(sensor) == 1 &amp;&amp; flag == 0)
  {
    delay(1000);
    if (digitalRead(sensor) == 1)
    {
      digitalWrite(led, HIGH);
      sendSMS(&quot;Low Soil Moisture detected. Motor turned ON&quot;);
      lcd.begin(16, 2);
      lcd.setCursor(0, 1);
      lcd.print(&quot;Motor ON &quot;);
      digitalWrite(motor, HIGH);
      delay(2000);
      flag=1;
    }
  } else if(digitalRead(sensor) == 0 &amp;&amp; flag == 1)
  {
    delay(1000);
    if (digitalRead(sensor) == 0)
    {
      digitalWrite(led, LOW);
      sendSMS(&quot;Soil Moisture is Normal. Motor turned OFF&quot;); 
      digitalWrite(motor, LOW);
      lcd.begin(16, 2);
      lcd.print(&quot;Motor OFF&quot;);
      lcd.setCursor(0, 1);
      lcd.print(&quot;Motor OFF&quot;);
      delay(2000);
      flag = 0;
    }
  }
}

void sendSMS(String msg)
{
  lcd.clear();
  lcd.print(&quot;Sending SMS&quot;);
  Serial1.println(&quot;AT+CMGF=1&quot;);
  delay(500);
  Serial1.print(&quot;AT+CMGS=&quot;);
  Serial1.print('&quot;');
  Serial1.print(&quot;+918xxxxxxxxx&quot;); // number
  Serial1.print('&quot;');
  Serial1.println();
  delay(500);
  Serial1.println(msg);
  delay(500);
  Serial1.write(26);
  delay(1000);
  lcd.clear();
  lcd.print(&quot;SMS Sent&quot;);
  delay(1000);
  lcd.begin(16, 2);
}

void gsmInit()
{
  lcd.clear();
  lcd.print(&quot;Finding Module..&quot;);
  boolean at_flag = 1;
  while (at_flag)
  {
    Serial1.println(&quot;AT&quot;);
    while (Serial1.available() &gt; 0)
    {
      if (Serial1.find(&quot;OK&quot;))
      at_flag = 0;
    }
    delay(1000);
  }
  Serial1.println(&quot;ATE0&quot;); //&lt;=== it says 'Serial1' was not declared in this scope
  lcd.clear();
  lcd.print(&quot;Finding Network..&quot;);
  boolean net_flag = 1;
  while(net_flag)
  {
    Serial1.println(&quot;AT+CPIN?&quot;);
    while(Serial1.available() &gt; 0)
    {
      if (Serial1.find(&quot;READY&quot;))
        net_flag = 0;
      break;
    }
    delay(1000);
  }
  Serial1.println(&quot;AT+CNMI=2,2,0,0,0&quot;);
  delay(1000);
  Serial1.println(&quot;AT+CMGF=1&quot;);
  delay(1000);
  Serial1.println(&quot;AT+CSMP=17,167,0,0&quot;);
  lcd.clear();
  Serial1.flush();
}
The UNO only has one serial port, named Serial.  You can create another one using SoftwareSerial (which you have included but not used) and you can, if you choose, name this Serial1.

#include &lt;SoftwareSerial.h&gt;

SoftwareSerial Serial1(4, 5); // RX, TX