I am getting error while compiling this sketch. Please help in correcting this

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int LDR = A0;// LDR input
const int LDRValue = 699;

const int PIR1 = A1;//PIR1 Gate sensor 1
const int PIR2 = A2;//PIR2 Lobby sensor 2
const int PIR3 = A3;//PIR3 Room sensor 3
const int PIR4 = A4;//PIR4 Roof sensor 4

bool j = false;
bool k = false;
bool l = false;
bool m = false;

#define GATE 6
#define LOBBY 7
#define ROOM 8
#define ROOF 9
#define RELAY 10

char str[15];
const int temp=0,i=0;

void setup()//Put your setup or configuration code in the setup function, it will only run once during the startup
{
pinMode(PIR1, INPUT);//Relay for Gate Light is connected to this pin as OUTPUT.
pinMode(PIR2, INPUT);//Relay for Lobby Light is connected to this pin as OUTPUT.
pinMode(PIR3, INPUT);//Relay for Room light is connected to this pin as OUTPUT.
pinMode(PIR4, INPUT);//Relay for Roof light is conencted to this pin as OUTPUT.
pinMode(LDR, INPUT);//Relay for Auto light ON and OFF is connected to this pin as OUTPUT.

digitalWrite(PIR1, LOW);
digitalWrite(PIR2, LOW);
digitalWrite(PIR3, LOW);
digitalWrite(PIR4, LOW);
digitalWrite(LDR, LOW);

delay(1000);
}

void loop()

{
PIR1();
PIR2();
PIR3();
PIR4();
}
void PIR1()
{
if(digitalRead(PIR2)==LOW==&&digitalRead(PIR1)==HIGH&&k==false)

{
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE NEAR GATE”);
Serial.write(0x1A);
delay(1000);
j = true;
k = false;

}
if(digitalRead(PIR1)==LOW==&&digitalRead(PIR2)==HIGH&&j==false)

{
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE IN LOBBY”);
Serial.write(0x1A);
delay(1000);
k = true;
j = false;
}
void PIR3()
{
if(digitalRead(PIR4)==LOW==&&digitalRead(PIR3)==HIGH&&m==false)

{
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE IN ROOM”);
Serial.write(0x1A);
delay(1000);
l = true;
m = false;

}
if(digitalRead(PIR3)==LOW==&&digitalRead(PIR4)==HIGH&&l==false)

{
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE ON ROOF”);
Serial.write(0x1A);
delay(1000);
m = true;
l = false;
}
void checkLDRValue();//Check whether it is bright or dark outside using LDR and Switch ON or OFF Lights.
{
if(LDRValue<=700)
digitalWrite(RELAY,HIGH);
Serial.println(“IT IS DARK OUTSIDE”);
}

if(LDRValue>700)
digitalWrite(RELAY,LOW);
Serial.println(“IT IS BRIGHT OUTSIDE”);
}
}

void checkSerialevent();//Check whether there is any message for Turning Lights ON or OFF using SMS.
{
Serial.println(“AT+CNMI=2,2,0,0”);
delay(500);
Serial.println(“AT+CMGF=1”);

while(Serial.available());
{
char inChar = (char)
Serial.read();
delay(1000);
while (Serial.available());
{
char inChar=Serial.read();
str[i++]=inChar;
if(inChar==’*’)
{
temp=1;
return;
}
}
void check();{

if(!(strncmp(str,“GATE ON”,5)))

{
digitalWrite(GATE, HIGH);
}

else if(!(strncmp(str,“GATE OFF”,6)))
{
digitalWrite(GATE, LOW);
}
else if(!(strncmp(str,“LOBBY ON”,5)))
{
digitalWrite(LOBBY, HIGH);
}
else if(!(strncmp(str,“LOBBY OFF”,7)))
{
digitalWrite(LOBBY, LOW);
}

else if(!(strncmp(str,“ROOM ON”,8)))
{
digitalWrite(ROOM, HIGH);
}
else if(!(strncmp(str,“ROOM OFF”,9)))
{
digitalWrite(ROOM, LOW);
}
if(!(strncmp(str,“ROOF ON”,8)))
{
digitalWrite(ROOF, HIGH);
}
else if(!(strncmp(str,“ROOF OFF”,9)))
{
digitalWrite(ROOF, LOW);
}
else if(!(strncmp(str,“ALL ON”,6)))
{
digitalWrite(GATE, HIGH);
digitalWrite(LOBBY, HIGH);
digitalWrite(ROOM, HIGH);
digitalWrite(ROOF, HIGH);
}
else if(!(strncmp(str,“ALL OFF”,7)))
{
digitalWrite(GATE, LOW);
digitalWrite(LOBBY, LOW);
digitalWrite(ROOM, LOW);
digitalWrite(ROOF, LOW);
}
}
void delSMS();//Delete all messages
{
Serial.println(“AT+CMGF=1”);//Did not help
delay(1000);
Serial.print(“AT+CMGDA=1"”);
Serial.println(“DEL ALL”");
delay(500);
Serial.println(“All Messages Deleted”);
lcd.clear();
lcd.print(“SYSTEM ON”);
}

Please post code within </> code-tags and use ctrl-t (auto format) for easier reading so we can all observe braces and program structure. this line (and similar ones) stands out for me if(digitalRead(PIR2)==LOW==&&digitalRead(PIR1)==HIGH&&k==false) and i figure it is supposed to be something like this if(digitalRead(PIR2)==LOW) && (digitalRead(PIR1)==HIGH) && (k==false)) the ==&& combination can hardly do what you expect it to do (personally i don’t know what to expect from it) but without you posting the ‘full’ compiler error msg (also please within </> code-tags) it is still a guessing game.

Arduino: 1.8.8 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

ROHTASH:9:11: error: 'const int PIR1' redeclared as different kind of symbol

const int PIR1 = A1;//PIR1 Gate sensor 1

^

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino:53:6: note: previous declaration 'void PIR1()'

void PIR1()

^

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino: In function 'void setup()':

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino:30:20: warning: invalid conversion from 'void (*)()' to 'uint8_t {aka unsigned char}' [-fpermissive]

pinMode(PIR1, INPUT);//Relay for Gate Light is connected to this pin as OUTPUT.

^

In file included from sketch\ROHTASH.ino.cpp:1:0:

C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: initializing argument 1 of 'void pinMode(uint8_t, uint8_t)'

void pinMode(uint8_t, uint8_t);

^

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino:36:23: warning: invalid conversion from 'void (*)()' to 'uint8_t {aka unsigned char}' [-fpermissive]

digitalWrite(PIR1, LOW);

^

In file included from sketch\ROHTASH.ino.cpp:1:0:

C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: initializing argument 1 of 'void digitalWrite(uint8_t, uint8_t)'

void digitalWrite(uint8_t, uint8_t);

^

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino: In function 'void loop()':

ROHTASH:49:6: error: 'PIR2' cannot be used as a function

PIR2();

^

ROHTASH:50:6: error: 'PIR3' cannot be used as a function

PIR3();

^

ROHTASH:51:6: error: 'PIR4' cannot be used as a function

PIR4();

^

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino: In function 'void PIR1()':

ROHTASH:55:31: error: expected identifier before '(' token

if(digitalRead(PIR2)==LOW) && (digitalRead(PIR1)==HIGH) && (k==false))

^

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino:73:20: warning: invalid conversion from 'void (*)()' to 'uint8_t {aka unsigned char}' [-fpermissive]

if(digitalRead(PIR1)==LOW) && (digitalRead(PIR2)==HIGH) && (j==false))

^

In file included from sketch\ROHTASH.ino.cpp:1:0:

C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:135:5: note: initializing argument 1 of 'int digitalRead(uint8_t)'

int digitalRead(uint8_t);

^

ROHTASH:73:31: error: expected identifier before '(' token

if(digitalRead(PIR1)==LOW) && (digitalRead(PIR2)==HIGH) && (j==false))

^

ROHTASH:91:1: error: a function-definition is not allowed here before '{' token

{

^

ROHTASH:223:1: error: expected '}' at end of input

}

^

exit status 1
'const int PIR1' redeclared as different kind of symbol

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

You can’t have functions with the same name as variables or constants.

Please remember to use code tags when posting code

Please correct it and send it to me back

You've been told what's wrong; correct it yourself.

Yes, that's not how it works round here. We tell you what is wrong and you do the corrections.

So once more, what's wrong is you have pins called PIR1, PIR2, PIR3 and PIR4 and you also have functions called PIR1 and PIR3. You can't have two different things with exactly the same name so you need to change the names of either the pins, e.g. call them PIR1pin, PIR2pin etc, or the functions.

And then in loop() you call functions PIR1(), PIR2(), PIR3() and PIR4() but you haven't defined functions PIR2() and PIR4() anywhere.

Steve

Done needful but still errors

KULRIA99:
Done needful but still errors

Ok, well now you need to post the amended code and say what those new errors are.

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int LDRpin = A0;// LDR input
const int LDRValue = 699;

const int PIR1pin = A1;//Gate sensor 1
const int PIR2pin = A2;//Lobby sensor 2
const int PIR3pin = A3;//Room sensor 3
const int PIR4pin = A4;//Roof sensor 4

bool j = false;
bool k = false;
bool l = false;
bool m = false;

#define GATE 6
#define LOBBY 7
#define ROOM 8
#define ROOF 9
#define RELAY 10

char str[15];
const int temp=0,i=0;

void setup()//Put your setup or configuration code in the setup function, it will only run once during the startup
{
pinMode(PIR1pin,INPUT);
pinMode(PIR2pin,INPUT);
pinMode(PIR3pin,INPUT);
pinMode(PIR4pin,INPUT);
pinMode(LDRpin,INPUT);

digitalWrite(PIR1pin,LOW);
digitalWrite(PIR2pin,LOW);
digitalWrite(PIR3pin,LOW);
digitalWrite(PIR4pin,LOW);
digitalWrite(LDRpin,LOW);

delay(1000);
}

void checkPIR1()
{
if(digitalRead(PIR2)==LOW) && (digitalRead(PIR1)==HIGH) && (k==false))

}
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE NEAR GATE”);
Serial.write(0x1A);
delay(1000);
j = true;
k = false;

}
void check PIR2()
{
if(digitalRead(PIR1)==LOW) && (digitalRead(PIR2)==HIGH) && (j==false))

{
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE IN LOBBY”);
Serial.write(0x1A);
delay(1000);
k = true;
j = false;
}
void checkPIR3()
{
if(digitalRead(PIR4)==LOW) && (digitalRead(PIR3)==HIGH) && (m==false))

{
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE IN ROOM”);
Serial.write(0x1A);
delay(1000);
l = true;
m = false;

}
void checkPIR4()
{
if(digitalRead(PIR3)==LOW) && (digitalRead(PIR4)==HIGH) && (l==false))

{
Serial.println(“OK”);
delay(1000);
Serial.print(“AT+CMGF=1\r\n”);
delay(500);
Serial.print(“AT+CMGS=”");
Serial.print("+9195xxxxxxxx");
Serial.print("“r\n”);
delay(2000);
Serial.print(“SOMEONE ON ROOF”);
Serial.write(0x1A);
delay(1000);
m = true;
l = false;
}
void checkLDRValue();//Check whether it is bright or dark outside using LDR and Switch ON or OFF Lights.
{
if(LDRValue<=700)
digitalWrite(RELAY,HIGH);
Serial.println(“IT IS DARK OUTSIDE”);
}

if(LDRValue>700)
digitalWrite(RELAY,LOW);
Serial.println(“IT IS BRIGHT OUTSIDE”);
}
}

void checkSerialevent();//Check whether there is any message for Turning Lights ON or OFF using SMS.
{
Serial.println(“AT+CNMI=2,2,0,0”);
delay(500);
Serial.println(“AT+CMGF=1”);

while(Serial.available());
{
char inChar = (char)
Serial.read();
delay(1000);
while (Serial.available());
{
char inChar=Serial.read();
str[i++]=inChar;
if(inChar==’*’)
{
temp=1;
return;
}
}
void check();{

if(!(strncmp(str,“GATE ON”,5)))

{
digitalWrite(GATE, HIGH);
}

else if(!(strncmp(str,“GATE OFF”,6)))
{
digitalWrite(GATE, LOW);
}
else if(!(strncmp(str,“LOBBY ON”,5)))
{
digitalWrite(LOBBY, HIGH);
}
else if(!(strncmp(str,“LOBBY OFF”,7)))
{
digitalWrite(LOBBY, LOW);
}

else if(!(strncmp(str,“ROOM ON”,8)))
{
digitalWrite(ROOM, HIGH);
}
else if(!(strncmp(str,“ROOM OFF”,9)))
{
digitalWrite(ROOM, LOW);
}
if(!(strncmp(str,“ROOF ON”,8)))
{
digitalWrite(ROOF, HIGH);
}
else if(!(strncmp(str,“ROOF OFF”,9)))
{
digitalWrite(ROOF, LOW);
}
else if(!(strncmp(str,“ALL ON”,6)))
{
digitalWrite(GATE, HIGH);
digitalWrite(LOBBY, HIGH);
digitalWrite(ROOM, HIGH);
digitalWrite(ROOF, HIGH);
}
else if(!(strncmp(str,“ALL OFF”,7)))
{
digitalWrite(GATE, LOW);
digitalWrite(LOBBY, LOW);
digitalWrite(ROOM, LOW);
digitalWrite(ROOF, LOW);
}
}
void delSMS();//Delete all messages
{
Serial.println(“AT+CMGF=1”);//Did not help
delay(1000);
Serial.print(“AT+CMGDA=1"”);
Serial.println(“DEL ALL”");
delay(500);
Serial.println(“All Messages Deleted”);
lcd.clear();
lcd.print(“SYSTEM ON”);
}

We need to see the errors and code tags.

Arduino: 1.8.8 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino: In function 'void checkPIR1()':

ROHTASH:48:16: error: 'PIR2' was not declared in this scope

if(digitalRead(PIR2)==LOW) && (digitalRead(PIR1)==HIGH) && (k==false))

^

ROHTASH:48:31: error: expected identifier before '(' token

if(digitalRead(PIR2)==LOW) && (digitalRead(PIR1)==HIGH) && (k==false))

^

D:\ARDUINO SKETCHES\ROHTASH\ROHTASH.ino: At global scope:

ROHTASH:51:3: error: 'Serial' does not name a type

Serial.println("OK");

^

ROHTASH:52:8: error: expected constructor, destructor, or type conversion before '(' token

delay(1000);

^

ROHTASH:53:3: error: 'Serial' does not name a type

Serial.print("AT+CMGF=1\r\n");

^

ROHTASH:54:8: error: expected constructor, destructor, or type conversion before '(' token

delay(500);

^

ROHTASH:55:3: error: 'Serial' does not name a type

Serial.print("AT+CMGS="");

^

ROHTASH:56:3: error: 'Serial' does not name a type

Serial.print("+9195xxxxxxxx");

^

ROHTASH:57:3: error: 'Serial' does not name a type

Serial.print(""r\n");

^

ROHTASH:58:8: error: expected constructor, destructor, or type conversion before '(' token

delay(2000);

^

ROHTASH:59:3: error: 'Serial' does not name a type

Serial.print("SOMEONE NEAR GATE");

^

ROHTASH:60:3: error: 'Serial' does not name a type

Serial.write(0x1A);

^

ROHTASH:61:8: error: expected constructor, destructor, or type conversion before '(' token

delay(1000);

^

ROHTASH:62:3: error: 'j' does not name a type

j = true;

^

ROHTASH:63:3: error: 'k' does not name a type

k = false;

^

ROHTASH:65:1: error: expected declaration before '}' token

}

^

exit status 1
'PIR2' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please always do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar, then you can manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

I'm going to guess, just as an example and absent any error messages, that this:

void checkPIR1()
{
if(digitalRead(PIR2)==LOW) && (digitalRead(PIR1)==HIGH) && (k==false))

}
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+9195xxxxxxxx");
  Serial.print("\"r\n");
  delay(2000);
  Serial.print("SOMEONE NEAR GATE");
  Serial.write(0x1A);
  delay(1000);
  j = true;
  k = false;

}

...should be (note lines with XXXXX):

void checkPIR1()
{
if(digitalRead(PIR2)==LOW) && (digitalRead(PIR1)==HIGH) && (k==false))

{ //not } XXXXXXXXXX
  Serial.println("OK");
  delay(1000);
  Serial.print("AT+CMGF=1\r\n");
  delay(500);
  Serial.print("AT+CMGS=\"");
  Serial.print("+9195xxxxxxxx");
  Serial.print("\"r\n");
  delay(2000);
  Serial.print("SOMEONE NEAR GATE");
  Serial.write(0x1A);
  delay(1000);
  j = true;
  k = false;

} // note extra } XXXXXXX
}

Please send me full sketch

KULRIA99:
Please send me full sketch

Please send money first.