user67927: I have a error.The error is showing as:
exit status 1
Error compiling for board Arduino Mega or Mega 2560.
The Code is:
#include <Wire.h>

#include <LCD.h>

#include <LiquidCrystal_I2C.h>

#include <SoftwareSerial.h>

LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

SoftwareSerial BT(10,11); //Tx and Rx pins for BT communication const int temp_sensor = 0; //pin A0 (temperature sensor) const int fan = 22; //pin D2 (fan) float temp; //temperature value

int threshold = 21; //temperature threshold

const int LDRsensor = 1; //pin A1 (lighting sensor)

const int LED1 = 6; //pin D6 (LED 1)

const int LED2 = 7; //pin D7 (LED 2)

const int LED3 = 8; //pin D8 (LED 3)

const int LED4 = 9; //pin D9 (LED 4)

int LDRvalue; //natural light value

const int WL_sensor = 15; //pin A15 (water level sensor)

const int Wpump = 13; //pin D13 (water pump)

float water_level; //water level value

const int mov_sensor = 3; //pin D3 (movement sensor)

const int LEDalrm = 4; //pin D4 (alarm LED)

const int buzzer = 5; //pin D5 (buzzer)

int mov_value; //movement value (true or false)

char state; //data sent from App

char mode; //mode selected according to "state" value char order; //order to actuators according to "state" value
void setup() //this function is only executed one time

{

lcd.begin (16,2);

lcd.setBacklightPin(3,POSITIVE);

lcd.setBacklight(HIGH);

lcd.setCursor(0,0);

lcd.print("TFG");

lcd.setCursor(0,1);

lcd.print("Anna Merino");

delay(4000);

lcd.clear();

pinMode(temp_sensor, INPUT); //temperature sensor Mode

pinMode(fan, OUTPUT) ; //fan Mode

pinMode(LDRsensor, INPUT); //lighting sensor Mode

pinMode(LED1, OUTPUT); //LED1 Mode

pinMode(LED2, OUTPUT); //LED2 Mode

pinMode(LED3, OUTPUT); //LED3 Mode

pinMode(LED4, OUTPUT); //LED4 Mode

pinMode(WL_sensor, INPUT) ; //water level sensor Mode

pinMode(Wpump, OUTPUT); //water pump Mode

pinMode(mov_sensor, INPUT); //movement sensor Mode

pinMode(LEDalrm, OUTPUT); //alarm LED Mode

pinMode(buzzer, OUTPUT); //buzzer Mode

BT.begin(9600); //set data rate in bits per second (baud) for data transmission }
void loop() //function loop – continuously executed

{

if(BT.available()>0)

{

state = BT.read(); //transfer data sent by App to a local variable

}

if (state == 'Y')

{

mode = 'A';

}

else

if (state == 'Z')

{

mode = 'R';

}

else

if (state == 'X')

{

mode = 'D';

}


if (mode == 'A')

{

automaticmode(); //execute automatic function

}

else

if (mode == 'R')

{

remotemode(); //execute remote function

}

else

if (mode == 'D')

{

alarmmode(); //execute alarm function

}

}
void alarmmode() // alarm function

{

water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable

if (digitalRead(mov_sensor)) //evaluate movement captured {

digitalWrite(LEDalrm, HIGH);

digitalWrite(buzzer, HIGH);

}

else

{

digitalWrite(LEDalrm, LOW);

digitalWrite(buzzer, LOW);

}

if (water_level > 100) //water level control

{

digitalWrite(Wpump, HIGH);

}

else

{

digitalWrite(Wpump, LOW);

}

}
void automaticmode() // automatic function

{

LDRvalue = analogRead(LDRsensor); //data of natural light transmission to a local variable water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable

temp = analogRead(temp_sensor); //data of temperature sensor transmission to a local variable temp = temp*0.4883; //adjustment of temperature value digitalWrite(LEDalrm, LOW);

digitalWrite(buzzer, LOW);

lcd.setCursor(0,0);

lcd.print("Temperature");

lcd.setCursor(0,1);

lcd.print(temp); //LCD display – shows temperature value

lcd.setCursor(7,1);

lcd.print("ºC");


if (water_level > 100) //water level control

{

digitalWrite(Wpump, HIGH);

}

else

{

digitalWrite(Wpump, LOW);

}


if ((LDRvalue < 1023) & (LDRvalue >= 822)) //light control {

digitalWrite(LED1, LOW);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

}

else if ((LDRvalue < 821)& (LDRvalue >= 617))

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);

}

else if ((LDRvalue < 616)& (LDRvalue >= 412))

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

}

else if ((LDRvalue < 411)& (LDRvalue >= 206))

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, HIGH);

digitalWrite(LED4, LOW);

}

else if (LDRvalue < 205)

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, HIGH);

digitalWrite(LED4, HIGH);

}


if (temp >= threshold) //temperature control

{

digitalWrite(fan, HIGH);

}

else if (temp < threshold)

{

digitalWrite(fan, LOW);

}

}

 

void remotemode() // remote function

{

digitalWrite(LED1, LOW);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

digitalWrite(fan, LOW);

digitalWrite(Wpump, LOW);

digitalWrite(LEDalrm, LOW);

digitalWrite(buzzer, LOW);


if(BT.available()>0)

{

state = BT.read(); //transfer data sent by App to a local variable

}


if (state == 'D') //actuators operation according to orders received {

digitalWrite(LED1, LOW);

}

else

if (state == 'C')

{

digitalWrite(LED1, HIGH);

}

else

if (state == 'F')

{

digitalWrite(LED2, LOW);

}

else

if (state == 'E')

{

digitalWrite(LED2, HIGH);

}

else

if (state == 'H')
{

digitalWrite(LED3, LOW);

}

else

if (state == 'G')

{

digitalWrite(LED3, HIGH);

}

else

if (state == 'J')

{

digitalWrite(LED4, LOW);

}

else

if (state == 'I')

{

digitalWrite(LED4, HIGH);

}

else

if (state == 'L')

{

digitalWrite(fan, LOW);

}

else

if (state == 'K')

{

digitalWrite(fan, HIGH);

}

else

if (state == 'N')

{

digitalWrite(Wpump, LOW);

}

else

if (state == 'M')

{

digitalWrite(Wpump, HIGH);

}
if (state == 'O')

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, HIGH);

digitalWrite(LED4, HIGH);

}

else

if (state == 'P')

{

digitalWrite(LED1, LOW);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

}


}


user10187: The main issue with your code is the formatting. It seems that you have managed to 'comment out' some of the necessary { or } for some of the functions and/or if/else blocks, hence the failure to compile.
e.g.
BT.begin(9600); //set data rate in bits per second (baud) for data transmission }

The } at the end of that particular line is the closing brace for the void setup() function... but because it's after the // for the comment, the compiler won't see it, so it is effectively missing.
This code should now compile on your system... once all the missing { and } were un-commented.
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);
SoftwareSerial BT(10, 11); //Tx and Rx pins for BT communication const int temp_sensor = 0; //pin A0 (temperature sensor) const int fan = 22; //pin D2 (fan) float temp; //temperature value

int threshold = 21; //temperature threshold

const int LDRsensor = 1; //pin A1 (lighting sensor)
const int LED1 = 6; //pin D6 (LED 1)
const int LED2 = 7; //pin D7 (LED 2)
const int LED3 = 8; //pin D8 (LED 3)
const int LED4 = 9; //pin D9 (LED 4)
const int WL_sensor = 15; //pin A15 (water level sensor)
const int Wpump = 13; //pin D13 (water pump)
const int mov_sensor = 3; //pin D3 (movement sensor)
const int LEDalrm = 4; //pin D4 (alarm LED)
const int buzzer = 5; //pin D5 (buzzer)

int LDRvalue; //natural light value
float water_level; //water level value
int mov_value; //movement value (true or false)

char state; //data sent from App
char mode;   //mode selected according to "state" value char order; //order to actuators according to "state" value

void setup() //this function is only executed one time
{
    lcd.begin(16, 2);
    lcd.setBacklightPin(3, POSITIVE);
    lcd.setBacklight(HIGH);

    lcd.setCursor(0, 0);
    lcd.print("TFG");
    lcd.setCursor(0, 1);
    lcd.print("Anna Merino");

    delay(4000);

    lcd.clear();

    pinMode(temp_sensor, INPUT); //temperature sensor Mode
    pinMode(fan, OUTPUT); //fan Mode
    pinMode(LDRsensor, INPUT); //lighting sensor Mode
    pinMode(LED1, OUTPUT); //LED1 Mode
    pinMode(LED2, OUTPUT); //LED2 Mode
    pinMode(LED3, OUTPUT); //LED3 Mode
    pinMode(LED4, OUTPUT); //LED4 Mode
    pinMode(WL_sensor, INPUT); //water level sensor Mode
    pinMode(Wpump, OUTPUT); //water pump Mode
    pinMode(mov_sensor, INPUT); //movement sensor Mode
    pinMode(LEDalrm, OUTPUT); //alarm LED Mode
    pinMode(buzzer, OUTPUT); //buzzer Mode

    BT.begin(9600); //set data rate in bits per second (baud) for data transmission
}

void loop() //function loop – continuously executed
{
    if (BT.available() > 0)
    {
        state = BT.read(); //transfer data sent by App to a local variable
    }

    if (state == 'Y')
    {
        mode = 'A';
    }
    else if (state == 'Z')
    {
        mode = 'R';
    }
    else if (state == 'X')
    {
        mode = 'D';
    }

    if (mode == 'A')
    {
        automaticmode(); //execute automatic function
    }
    else if (mode == 'R')
    {
        remotemode(); //execute remote function
    }
    else if (mode == 'D')
    {
        alarmmode(); //execute alarm function
    }
}

void alarmmode() // alarm function
{
    water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable

    if (digitalRead(mov_sensor)) //evaluate movement captured
    {
        digitalWrite(LEDalrm, HIGH);
        digitalWrite(buzzer, HIGH);
    }
    else
    {
        digitalWrite(LEDalrm, LOW);
        digitalWrite(buzzer, LOW);
    }
    if (water_level > 100) //water level control
    {
        digitalWrite(Wpump, HIGH);
    }
    else
    {
        digitalWrite(Wpump, LOW);
    }
}

void automaticmode() // automatic function
{
    LDRvalue = analogRead(LDRsensor); //data of natural light transmission to a local variable water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable
    temp = analogRead(temp_sensor); //data of temperature sensor transmission to a local variable temp = temp*0.4883; //adjustment of temperature value digitalWrite(LEDalrm, LOW);

    digitalWrite(buzzer, LOW);

    lcd.setCursor(0, 0);
    lcd.print("Temperature");

    lcd.setCursor(0, 1);
    lcd.print(temp); //LCD display – shows temperature value

    lcd.setCursor(7, 1);
    lcd.print("ºC");

    if (water_level > 100) //water level control
    {
        digitalWrite(Wpump, HIGH);
    }
    else
    {
        digitalWrite(Wpump, LOW);
    }

    if ((LDRvalue < 1023) & (LDRvalue >= 822)) //light control
    {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
    else if ((LDRvalue < 821) & (LDRvalue >= 617))
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, LOW);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
    else if ((LDRvalue < 616) & (LDRvalue >= 412))
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
    else if ((LDRvalue < 411) & (LDRvalue >= 206))
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, HIGH);
        digitalWrite(LED4, LOW);
    }
    else if (LDRvalue < 205)
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, HIGH);
        digitalWrite(LED4, HIGH);
    }

    if (temp >= threshold) //temperature control
    {
        digitalWrite(fan, HIGH);
    }
    else if (temp < threshold)
    {
        digitalWrite(fan, LOW);
    }
}

void remotemode() // remote function
{
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);

    digitalWrite(fan, LOW);
    digitalWrite(Wpump, LOW);
    digitalWrite(LEDalrm, LOW);
    digitalWrite(buzzer, LOW);

    if (BT.available() > 0)
    {
        state = BT.read(); //transfer data sent by App to a local variable
    }

    if (state == 'D') //actuators operation according to orders received
    {
        digitalWrite(LED1, LOW);
    }
    else if (state == 'C')
    {
        digitalWrite(LED1, HIGH);
    }
    else if (state == 'F')
    {
        digitalWrite(LED2, LOW);
    }
    else if (state == 'E')
    {
        digitalWrite(LED2, HIGH);
    }
    else if (state == 'H')
    {
        digitalWrite(LED3, LOW);
    }
    else if (state == 'G')
    {
        digitalWrite(LED3, HIGH);
    }
    else if (state == 'J')
    {
        digitalWrite(LED4, LOW);
    }
    else if (state == 'I')
    {
        digitalWrite(LED4, HIGH);
    }
    else if (state == 'L')
    {
        digitalWrite(fan, LOW);
    }
    else if (state == 'K')
    {
        digitalWrite(fan, HIGH);
    }
    else if (state == 'N')
    {
        digitalWrite(Wpump, LOW);
    }
    else if (state == 'M')
    {
        digitalWrite(Wpump, HIGH);
    }

    if (state == 'O')
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, HIGH);
        digitalWrite(LED4, HIGH);
    }
    else if (state == 'P')
    {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
}


In future, when posting a question, please also list WHICH libraries you are using. e.g. there is more than one LiquidCrystal_I2C library... and probably only one right one. Also, that will only be part of the error message. Give the entire message - as the end bit isn't of much use!

67927: <p>I have a error.The error is showing as:</p>
<p>exit status 1
Error compiling for board Arduino Mega or Mega 2560.</p>
<p>The Code is:</p>
<pre><code>#include &lt;Wire.h&gt;

#include &lt;LCD.h&gt;

#include &lt;LiquidCrystal_I2C.h&gt;

#include &lt;SoftwareSerial.h&gt;

LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

SoftwareSerial BT(10,11); //Tx and Rx pins for BT communication const int temp_sensor = 0; //pin A0 (temperature sensor) const int fan = 22; //pin D2 (fan) float temp; //temperature value

int threshold = 21; //temperature threshold

const int LDRsensor = 1; //pin A1 (lighting sensor)

const int LED1 = 6; //pin D6 (LED 1)

const int LED2 = 7; //pin D7 (LED 2)

const int LED3 = 8; //pin D8 (LED 3)

const int LED4 = 9; //pin D9 (LED 4)

int LDRvalue; //natural light value

const int WL_sensor = 15; //pin A15 (water level sensor)

const int Wpump = 13; //pin D13 (water pump)

float water_level; //water level value

const int mov_sensor = 3; //pin D3 (movement sensor)

const int LEDalrm = 4; //pin D4 (alarm LED)

const int buzzer = 5; //pin D5 (buzzer)

int mov_value; //movement value (true or false)

char state; //data sent from App

char mode; //mode selected according to &quot;state&quot; value char order; //order to actuators according to &quot;state&quot; value
void setup() //this function is only executed one time

{

lcd.begin (16,2);

lcd.setBacklightPin(3,POSITIVE);

lcd.setBacklight(HIGH);

lcd.setCursor(0,0);

lcd.print(&quot;TFG&quot;);

lcd.setCursor(0,1);

lcd.print(&quot;Anna Merino&quot;);

delay(4000);

lcd.clear();

pinMode(temp_sensor, INPUT); //temperature sensor Mode

pinMode(fan, OUTPUT) ; //fan Mode

pinMode(LDRsensor, INPUT); //lighting sensor Mode

pinMode(LED1, OUTPUT); //LED1 Mode

pinMode(LED2, OUTPUT); //LED2 Mode

pinMode(LED3, OUTPUT); //LED3 Mode

pinMode(LED4, OUTPUT); //LED4 Mode

pinMode(WL_sensor, INPUT) ; //water level sensor Mode

pinMode(Wpump, OUTPUT); //water pump Mode

pinMode(mov_sensor, INPUT); //movement sensor Mode

pinMode(LEDalrm, OUTPUT); //alarm LED Mode

pinMode(buzzer, OUTPUT); //buzzer Mode

BT.begin(9600); //set data rate in bits per second (baud) for data transmission }
void loop() //function loop – continuously executed

{

if(BT.available()&gt;0)

{

state = BT.read(); //transfer data sent by App to a local variable

}

if (state == 'Y')

{

mode = 'A';

}

else

if (state == 'Z')

{

mode = 'R';

}

else

if (state == 'X')

{

mode = 'D';

}


if (mode == 'A')

{

automaticmode(); //execute automatic function

}

else

if (mode == 'R')

{

remotemode(); //execute remote function

}

else

if (mode == 'D')

{

alarmmode(); //execute alarm function

}

}
void alarmmode() // alarm function

{

water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable

if (digitalRead(mov_sensor)) //evaluate movement captured {

digitalWrite(LEDalrm, HIGH);

digitalWrite(buzzer, HIGH);

}

else

{

digitalWrite(LEDalrm, LOW);

digitalWrite(buzzer, LOW);

}

if (water_level &gt; 100) //water level control

{

digitalWrite(Wpump, HIGH);

}

else

{

digitalWrite(Wpump, LOW);

}

}
void automaticmode() // automatic function

{

LDRvalue = analogRead(LDRsensor); //data of natural light transmission to a local variable water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable

temp = analogRead(temp_sensor); //data of temperature sensor transmission to a local variable temp = temp*0.4883; //adjustment of temperature value digitalWrite(LEDalrm, LOW);

digitalWrite(buzzer, LOW);

lcd.setCursor(0,0);

lcd.print(&quot;Temperature&quot;);

lcd.setCursor(0,1);

lcd.print(temp); //LCD display – shows temperature value

lcd.setCursor(7,1);

lcd.print(&quot;ºC&quot;);


if (water_level &gt; 100) //water level control

{

digitalWrite(Wpump, HIGH);

}

else

{

digitalWrite(Wpump, LOW);

}


if ((LDRvalue &lt; 1023) &amp; (LDRvalue &gt;= 822)) //light control {

digitalWrite(LED1, LOW);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

}

else if ((LDRvalue &lt; 821)&amp; (LDRvalue &gt;= 617))

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);

}

else if ((LDRvalue &lt; 616)&amp; (LDRvalue &gt;= 412))

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

}

else if ((LDRvalue &lt; 411)&amp; (LDRvalue &gt;= 206))

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, HIGH);

digitalWrite(LED4, LOW);

}

else if (LDRvalue &lt; 205)

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, HIGH);

digitalWrite(LED4, HIGH);

}


if (temp &gt;= threshold) //temperature control

{

digitalWrite(fan, HIGH);

}

else if (temp &lt; threshold)

{

digitalWrite(fan, LOW);

}

}

 

void remotemode() // remote function

{

digitalWrite(LED1, LOW);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

digitalWrite(fan, LOW);

digitalWrite(Wpump, LOW);

digitalWrite(LEDalrm, LOW);

digitalWrite(buzzer, LOW);


if(BT.available()&gt;0)

{

state = BT.read(); //transfer data sent by App to a local variable

}


if (state == 'D') //actuators operation according to orders received {

digitalWrite(LED1, LOW);

}

else

if (state == 'C')

{

digitalWrite(LED1, HIGH);

}

else

if (state == 'F')

{

digitalWrite(LED2, LOW);

}

else

if (state == 'E')

{

digitalWrite(LED2, HIGH);

}

else

if (state == 'H')
{

digitalWrite(LED3, LOW);

}

else

if (state == 'G')

{

digitalWrite(LED3, HIGH);

}

else

if (state == 'J')

{

digitalWrite(LED4, LOW);

}

else

if (state == 'I')

{

digitalWrite(LED4, HIGH);

}

else

if (state == 'L')

{

digitalWrite(fan, LOW);

}

else

if (state == 'K')

{

digitalWrite(fan, HIGH);

}

else

if (state == 'N')

{

digitalWrite(Wpump, LOW);

}

else

if (state == 'M')

{

digitalWrite(Wpump, HIGH);

}
if (state == 'O')

{

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, HIGH);

digitalWrite(LED4, HIGH);

}

else

if (state == 'P')

{

digitalWrite(LED1, LOW);

digitalWrite(LED2, LOW);

digitalWrite(LED3, LOW);

digitalWrite(LED4, LOW);

}


}
</code></pre>
 10187: <p>The main issue with your code is the formatting. It seems that you have managed to 'comment out' some of the necessary <code>{</code> or <code>}</code> for some of the functions and/or if/else blocks, hence the failure to compile.</p>
<p>e.g.</p>
<pre><code>BT.begin(9600); //set data rate in bits per second (baud) for data transmission }
</code></pre>
<p>The <code>}</code> at the end of that particular line is the closing brace for the <code>void setup()</code> function... but because it's after the <code>//</code> for the comment, the compiler won't see it, so it is effectively missing.</p>
<p>This code <em>should</em> now compile on your system... once all the missing <code>{</code> and <code>}</code> were un-commented.</p>
<pre><code>#include &lt;Wire.h&gt;
#include &lt;LCD.h&gt;
#include &lt;LiquidCrystal_I2C.h&gt;
#include &lt;SoftwareSerial.h&gt;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);
SoftwareSerial BT(10, 11); //Tx and Rx pins for BT communication const int temp_sensor = 0; //pin A0 (temperature sensor) const int fan = 22; //pin D2 (fan) float temp; //temperature value

int threshold = 21; //temperature threshold

const int LDRsensor = 1; //pin A1 (lighting sensor)
const int LED1 = 6; //pin D6 (LED 1)
const int LED2 = 7; //pin D7 (LED 2)
const int LED3 = 8; //pin D8 (LED 3)
const int LED4 = 9; //pin D9 (LED 4)
const int WL_sensor = 15; //pin A15 (water level sensor)
const int Wpump = 13; //pin D13 (water pump)
const int mov_sensor = 3; //pin D3 (movement sensor)
const int LEDalrm = 4; //pin D4 (alarm LED)
const int buzzer = 5; //pin D5 (buzzer)

int LDRvalue; //natural light value
float water_level; //water level value
int mov_value; //movement value (true or false)

char state; //data sent from App
char mode;   //mode selected according to &quot;state&quot; value char order; //order to actuators according to &quot;state&quot; value

void setup() //this function is only executed one time
{
    lcd.begin(16, 2);
    lcd.setBacklightPin(3, POSITIVE);
    lcd.setBacklight(HIGH);

    lcd.setCursor(0, 0);
    lcd.print(&quot;TFG&quot;);
    lcd.setCursor(0, 1);
    lcd.print(&quot;Anna Merino&quot;);

    delay(4000);

    lcd.clear();

    pinMode(temp_sensor, INPUT); //temperature sensor Mode
    pinMode(fan, OUTPUT); //fan Mode
    pinMode(LDRsensor, INPUT); //lighting sensor Mode
    pinMode(LED1, OUTPUT); //LED1 Mode
    pinMode(LED2, OUTPUT); //LED2 Mode
    pinMode(LED3, OUTPUT); //LED3 Mode
    pinMode(LED4, OUTPUT); //LED4 Mode
    pinMode(WL_sensor, INPUT); //water level sensor Mode
    pinMode(Wpump, OUTPUT); //water pump Mode
    pinMode(mov_sensor, INPUT); //movement sensor Mode
    pinMode(LEDalrm, OUTPUT); //alarm LED Mode
    pinMode(buzzer, OUTPUT); //buzzer Mode

    BT.begin(9600); //set data rate in bits per second (baud) for data transmission
}

void loop() //function loop – continuously executed
{
    if (BT.available() &gt; 0)
    {
        state = BT.read(); //transfer data sent by App to a local variable
    }

    if (state == 'Y')
    {
        mode = 'A';
    }
    else if (state == 'Z')
    {
        mode = 'R';
    }
    else if (state == 'X')
    {
        mode = 'D';
    }

    if (mode == 'A')
    {
        automaticmode(); //execute automatic function
    }
    else if (mode == 'R')
    {
        remotemode(); //execute remote function
    }
    else if (mode == 'D')
    {
        alarmmode(); //execute alarm function
    }
}

void alarmmode() // alarm function
{
    water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable

    if (digitalRead(mov_sensor)) //evaluate movement captured
    {
        digitalWrite(LEDalrm, HIGH);
        digitalWrite(buzzer, HIGH);
    }
    else
    {
        digitalWrite(LEDalrm, LOW);
        digitalWrite(buzzer, LOW);
    }
    if (water_level &gt; 100) //water level control
    {
        digitalWrite(Wpump, HIGH);
    }
    else
    {
        digitalWrite(Wpump, LOW);
    }
}

void automaticmode() // automatic function
{
    LDRvalue = analogRead(LDRsensor); //data of natural light transmission to a local variable water_level = analogRead(WL_sensor); //data of water level sensor transmission to a local variable
    temp = analogRead(temp_sensor); //data of temperature sensor transmission to a local variable temp = temp*0.4883; //adjustment of temperature value digitalWrite(LEDalrm, LOW);

    digitalWrite(buzzer, LOW);

    lcd.setCursor(0, 0);
    lcd.print(&quot;Temperature&quot;);

    lcd.setCursor(0, 1);
    lcd.print(temp); //LCD display – shows temperature value

    lcd.setCursor(7, 1);
    lcd.print(&quot;ºC&quot;);

    if (water_level &gt; 100) //water level control
    {
        digitalWrite(Wpump, HIGH);
    }
    else
    {
        digitalWrite(Wpump, LOW);
    }

    if ((LDRvalue &lt; 1023) &amp; (LDRvalue &gt;= 822)) //light control
    {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
    else if ((LDRvalue &lt; 821) &amp; (LDRvalue &gt;= 617))
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, LOW);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
    else if ((LDRvalue &lt; 616) &amp; (LDRvalue &gt;= 412))
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
    else if ((LDRvalue &lt; 411) &amp; (LDRvalue &gt;= 206))
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, HIGH);
        digitalWrite(LED4, LOW);
    }
    else if (LDRvalue &lt; 205)
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, HIGH);
        digitalWrite(LED4, HIGH);
    }

    if (temp &gt;= threshold) //temperature control
    {
        digitalWrite(fan, HIGH);
    }
    else if (temp &lt; threshold)
    {
        digitalWrite(fan, LOW);
    }
}

void remotemode() // remote function
{
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);

    digitalWrite(fan, LOW);
    digitalWrite(Wpump, LOW);
    digitalWrite(LEDalrm, LOW);
    digitalWrite(buzzer, LOW);

    if (BT.available() &gt; 0)
    {
        state = BT.read(); //transfer data sent by App to a local variable
    }

    if (state == 'D') //actuators operation according to orders received
    {
        digitalWrite(LED1, LOW);
    }
    else if (state == 'C')
    {
        digitalWrite(LED1, HIGH);
    }
    else if (state == 'F')
    {
        digitalWrite(LED2, LOW);
    }
    else if (state == 'E')
    {
        digitalWrite(LED2, HIGH);
    }
    else if (state == 'H')
    {
        digitalWrite(LED3, LOW);
    }
    else if (state == 'G')
    {
        digitalWrite(LED3, HIGH);
    }
    else if (state == 'J')
    {
        digitalWrite(LED4, LOW);
    }
    else if (state == 'I')
    {
        digitalWrite(LED4, HIGH);
    }
    else if (state == 'L')
    {
        digitalWrite(fan, LOW);
    }
    else if (state == 'K')
    {
        digitalWrite(fan, HIGH);
    }
    else if (state == 'N')
    {
        digitalWrite(Wpump, LOW);
    }
    else if (state == 'M')
    {
        digitalWrite(Wpump, HIGH);
    }

    if (state == 'O')
    {
        digitalWrite(LED1, HIGH);
        digitalWrite(LED2, HIGH);
        digitalWrite(LED3, HIGH);
        digitalWrite(LED4, HIGH);
    }
    else if (state == 'P')
    {
        digitalWrite(LED1, LOW);
        digitalWrite(LED2, LOW);
        digitalWrite(LED3, LOW);
        digitalWrite(LED4, LOW);
    }
}

</code></pre>
<p>In future, when posting a question, please also list <em>WHICH</em> libraries you are using. e.g. there is more than one <code>LiquidCrystal_I2C</code> library... and probably only one right one. Also, that will only be part of the error message. Give the entire message - as the end bit isn't of much use!</p>
