Errors in executing irrigation system program

 #include<LiquidCrystal.h>
> LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
> 
> void setup()
> {
>   // initialize digital pin 13 as an output.
>   pinMode(8, INPUT); //l
>   pinMode(13, OUTPUT); //L1
>   LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
>   Serial.begin(9600);
>   lcd.begin(16, 2); //We are using a16*2 LCD display
>   lcd.print("soil moisture");//Display a intro message
>   lcd.clear();
>   delay(2000);
> };
> int z;
> //the loop function runs over and over again forever
> void loop() {
>   z = digitalRead(8);
>   Serial.print(z);
>   if (z == 0)
>   {
>     digitalWrite(13, LOW);
>     lcd.setCursor(0, 0);
>     lcd.print("moisture full");
>   }
>   if else (z == 1) //forward
>     {
>       digitalwrite(13, HIGH);
>       lcd.setCursor(0, 0);
>       lcd.print("pump on……")
>     }
> }

Please guys help me out with these loads of errors.
I'm new to Arduino and searched a lot to solve these errors but couldn't solve them so please help me out.Preformatted text

Your improperly posted code is incomplete. Read the forum guidelines to see how to properly post code and some hints on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Oh okay
I apologize for the inconvenience as I am new to forums.

Here is your code posted properly and indented with the IDE autoformat tool. See the comments for the problems and solutions. Code compiles now, though I had to guess what you are trying to do in a couple of places. NOT tested.

#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup()
{
   // initialize digital pin 13 as an output.
   pinMode(8, INPUT); //l  *****  pinMode is not capitalized
   pinMode(13, OUTPUT); //L1 *****  pinMode is not capitalized
   //LiquidCrystal lcd(7, 6, 5, 4, 3, 2);  // **** does not belong here
   Serial.begin(9600);
   lcd.begin(16, 2); //We are using a16*2 LCD display
   lcd.print("soil moisture");//Display a intro message // **** print ! Print
   // class LiquidCrystal' has no member named 'serial'
   lcd.clear();
   delay(2000);
} //  *** no ; required
int z;
//the loop function runs over and over again forever
void loop(void)
{
   z = digitalRead(8);
   Serial.print(z);
   if (z == 0)
   {
      digitalWrite(13, LOW);
      lcd.setCursor(0, 0);
      lcd.print("moisture full");  // **** added missing ;
   }  //  *** no ; required;
   else if (z == 1) //forward
   {
      // *** should be { not }
      digitalWrite(13, HIGH);  // **** capital W case is important
      lcd.setCursor(0, 0);
      lcd.print("pump on……");  // **** added missing ;
   } // **** added } to close else if
}

So go back to the original post, select the code and click on the </> in the menu bar to post the code properly. It is that easy.

code tags new

Yes I did !!!!
I solved most of the error just one is left which is:

In function 'void loop()':
irrigation:27:6: error: expected '(' before 'else'
   if else (z == 1) //forward
      ^~~~
exit status 1
expected '(' before 'else'

I can't fix code that I can't see. The error is probably before that line of code. Post the code properly and I will try to help.

Check it now please.....

#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup()
{
  // initialize digital pin 13 as an output.
  pinMode(8, INPUT); //l
  pinMode(13, OUTPUT); //L1
  LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
  Serial.begin(9600);
  lcd.begin(16, 2); //We are using a16*2 LCD display
  lcd.print("soil moisture");//Display a intro message
  lcd.clear();
  delay(2000);
};
int z;
//the loop function runs over and over again forever
void loop() {
  z = digitalRead(8);
  Serial.print(z);
  if (z == 0)
  {
    digitalWrite(13, LOW);
    lcd.setCursor(0, 0);
    lcd.print("moisture full");
  }
  if else (z == 1) //forward
    {
      digitalwrite(13, HIGH);
      lcd.setCursor(0, 0);
      lcd.print("pump on……")
    }
}

ERROR:

In function 'void loop()':
irrigation:27:6: error: expected '(' before 'else'
   if else (z == 1) //forward
      ^~~~
exit status 1
expected '(' before 'else'

Please help me solve this error.

Why start an new thread? This is cross posting. Cross posting is bad.

You did not fix all the errors that I pointed out in the other thread.

It is else if not if else.
digitalWrite, not digitalwrite. capital W in the function
lcd.print("pump on……") needs a ; lcd.print("pump on……");

Lose the ; of }; at the end of setup()

If the compiler reports a error in a line such as;

irrigation:27:6: error: expected '(' before 'else'

Then think maybe there is an error in that line and it seems that the compiler has a problem with the 'if else'.

So look up the Arduino reference documents with a Google search on say 'Arduino reference if else'

Thank you all for helping me out.
Fortunately, I debugged all the errors and successfully compiled my program.

So maybe tell the forum what the errors were ?

@xyzbee
You have posted the same question twice and in the wrong place. If you wish to keep using the forum please follow the forum guidelines that were pointed out to you in reply #2.

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.