This problem is always occuring whenever i compling the code. why this problem happen? Can anyone please solve this

In file included from C:\Users\user\AppData\Local\Temp\arduino_build_411289\sketch\Security_GSM_Copy.ino.cpp:1:0:
C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:40:14: error: expected identifier before numeric constant
#define HIGH 0x1
^
E:\File\Programming\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
#define CLOSED HIGH
^~~~
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:44:5: note: in expansion of macro 'CLOSED'
CLOSED = 0,
^~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:40:14: error: expected '}' before numeric constant
#define HIGH 0x1
^
E:\File\Programming\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
#define CLOSED HIGH
^~~~
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:44:5: note: in expansion of macro 'CLOSED'
CLOSED = 0,
^~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant
#define HIGH 0x1
^
E:\File\Programming\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
#define CLOSED HIGH
^~~~
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:44:5: note: in expansion of macro 'CLOSED'
CLOSED = 0,
^~~~~~
In file included from D:\Project\Main File\Security_GSM_Copy\Security_GSM_Copy.ino:7:0:
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:47:1: error: expected declaration before '}' token
};

There are errors in your code, that you forgot to post.

"HIGH" is predefined for the compiler and you are not allowed to redefine it. It is in the predefined list word list. Change the case of one letter and it should work.

It looks like your libraries are conflicting with each other. The Keypad library is defining a macro for CLOSED to be equivalent to HIGH, but the GPRS_SIM900 library seems to be trying to use CLOSED as a variable name and assigning 0 to it. The same name is trying to be used 2 different ways.

I don't think it's possible to resolve this without rewriting one of the libraries to get rid of the conflict.

I am giving my code below:

#include <LiquidCrystal.h>
#include <Servo.h>
#include <Keypad.h>
#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>

//SoftwareSerial mySerial(0, 1);
#define PIN_TX 7
#define PIN_RX 8
#define BAUDRATE 9600
#define PHONE_NUMBER "18******" // I am hiding this because of my privacy
#define MESSAGE "hello,world"

Servo myservo;
int pos = 0; // position of servo motor

LiquidCrystal lcd(A4, A5, A3, A2, A1, A0);

const byte rows = 4;
const byte cols = 4;

char key[rows][cols] = {
{'7', '8', '9', 'A'},
{'4', '5', '6', 'B'},
{'1', '2', '3', 'C'},
{'C', '0', '#', 'D'}
};
byte rowPins[rows] = {9, 8, 7, 5}; //connect to the row pinouts of the keypad
byte colPins[cols] = {10, 11, 12, 13}; //connect to the column pinouts of the keypad

GPRS gprs(PIN_TX, PIN_RX, BAUDRATE); //RX,TX,BaudRate
Keypad customKeypad(makeKeymap(key), rowPins, colPins, rows, cols);//initialize an instance of class NewKeypad

//#define passwordsize 5
//char code[passwordsize];
//char password[passwordsize] = "1234";
char* password = "5566";
int currentposition = 0;

void setup()
{
myservo.attach(6); //Servo motor connection
lcd.begin(16, 2);
//mySerial.begin(9600); // Setting the baud rate of GSM Module (
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
gprs.checkPowerUp();
Serial.begin(9600);

while (!gprs.init())
{
delay(1000);
Serial.println("Initialization failed!");
}

while (!gprs.isNetworkRegistered())
{
delay(1000);
Serial.println("Network has not registered yet!");
}

Serial.println("gprs initialize done!");
Serial.println("start to send message ...");
}

void loop()
{
if (currentposition == 0)
{
displayscreen(); // for activate display.
}

int l ;
char code = customKeypad.getKey();
if (code != NO_KEY)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("PASSWORD:");
lcd.setCursor(7, 1);
lcd.print(" ");
lcd.setCursor(7, 1);
for (l = 0; l <= currentposition; ++l)
{
lcd.print("*");
// keypress();
}

if (code == password[currentposition])
{
  ++currentposition;
  if (currentposition == 4)
  {
    unlockdoor();
    currentposition = 0;
  }
}

else if (code != password[currentposition])
{
  ++currentposition;
  if (currentposition == 4)
  {
    incorrect();
    currentposition = 0;
  }
}

}
}

//------------------ Function 1- OPEN THE DOOR--------------//

void unlockdoor()
{
// delay(900);
lcd.setCursor(0, 0);
lcd.println(" ");
lcd.setCursor(1, 0);
lcd.print("Access Granted");
lcd.setCursor(4, 1);
lcd.println("WELCOME!!");
lcd.setCursor(15, 1);
lcd.println(" ");
lcd.setCursor(16, 1);
lcd.println(" ");
lcd.setCursor(14, 1);
lcd.println(" ");
lcd.setCursor(13, 1);
lcd.println(" ");

for (pos = 180; pos >= 0; pos -= 5) // open the door
{
myservo.write(pos);
delay(5);
}
delay(1000);

delay(1000);
counterbeep();

delay(1000);

for (pos = 0; pos <= 180; pos += 5) // close the door
{ // in steps of 1 degree
myservo.write(pos);
delay(15);

currentposition = 0;
lcd.clear();
displayscreen();

}
}

//--------------------Function 2- Wrong code--------------//

void incorrect()
{
delay(500);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("CODE");
lcd.setCursor(6, 0);
lcd.print("INCORRECT");
lcd.setCursor(15, 1);
lcd.println(" ");
lcd.setCursor(0, 1);
lcd.println("TRY AGAIN");
lcd.setCursor(13, 1);
lcd.println(" ");

SendMessage();
delay(3000);
lcd.clear();
displayscreen();
}
//-------Function 3 - CLEAR THE SCREEN--------------------/
void clearscreen()
{
lcd.setCursor(0, 0);
lcd.println(" ");
lcd.setCursor(0, 1);
lcd.println(" ");
lcd.setCursor(0, 2);
lcd.println(" ");
lcd.setCursor(0, 3);
lcd.println(" ");
}

//------------Function 4 - DISPLAY FUNCTION--------------------//
void displayscreen()
{

lcd.setCursor(0, 0);
lcd.println("ENTER THE CODE");
lcd.setCursor(1 , 1);
lcd.println("TO OPEN DOOR!!");
}

//--------For Sending Password------------ /
void SendMessage()
if (gprs.sendSMS(PHONE_NUMBER, MESSAGE)) { //define phone number and text
mySerial.print("Send SMS Succeed!\r\n");
} else {
mySerial.print("Send SMS failed!\r\n");
}

//--------------Function 5 - Count down------------------//
void counterbeep()
{
delay(1200);
lcd.clear();
lcd.setCursor(2, 15);
lcd.println(" ");
lcd.setCursor(2, 14);
lcd.println(" ");
lcd.setCursor(2, 0);
delay(200);
lcd.println("GET IN WITHIN:::");
lcd.setCursor(4, 1);
lcd.print("5");
delay(200);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
delay(1000);
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1); //2
lcd.print("4");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
delay(1000);

lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1);
lcd.print("3");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
delay(1000);

lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1);
lcd.print("2");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
delay(1000);

lcd.setCursor(4, 1);
lcd.print("1");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN::");

delay(1000);
delay(40);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("RE-LOCKING");
delay(500);
lcd.setCursor(12, 0);
lcd.print(".");
delay(500);
lcd.setCursor(13, 0);
lcd.print(".");
delay(500);
lcd.setCursor(14, 0);
lcd.print(".");
delay(400);
lcd.clear();
lcd.setCursor(4, 0);
lcd.print("LOCKED!");
delay(440);
}

This error message is showing all the time whenever I compile the code.

Error message:

In file included from C:\Users\user\AppData\Local\Temp\arduino_build_414718\sketch\Initial_design.ino.cpp:1:0:
C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:40:14: error: expected identifier before numeric constant
#define HIGH 0x1
^
E:\File\Programming\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
#define CLOSED HIGH
^~~~
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:44:5: note: in expansion of macro 'CLOSED'
CLOSED = 0,
^~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:40:14: error: expected '}' before numeric constant
#define HIGH 0x1
^
E:\File\Programming\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
#define CLOSED HIGH
^~~~
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:44:5: note: in expansion of macro 'CLOSED'
CLOSED = 0,
^~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant
#define HIGH 0x1
^
E:\File\Programming\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
#define CLOSED HIGH
^~~~
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:44:5: note: in expansion of macro 'CLOSED'
CLOSED = 0,
^~~~~~
In file included from D:\StudY\8th\Thesis\Project all document folder\Practice File\Initial_design\Initial_design.ino:5:0:
E:\File\Programming\Arduino\libraries\GPRS_SIM900-master/GPRS_Shield_Arduino.h:47:1: error: expected declaration before '}' token
};
^

Using the 'preformatted text ' option makes the code you post readable.

#include <LiquidCrystal.h>
#include <Servo.h>
#include <Keypad.h>
#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>

//SoftwareSerial mySerial(0, 1);
#define PIN_TX 7
#define PIN_RX 8
#define BAUDRATE 9600
#define PHONE_NUMBER "18******"                                       // I am hiding this because of my privacy
#define MESSAGE "hello,world"

Servo myservo;
int pos = 0; // position of servo motor

LiquidCrystal lcd(A4, A5, A3, A2, A1, A0);

const byte rows = 4;
const byte cols = 4;

char key[rows][cols] = {
  {'7', '8', '9', 'A'},
  {'4', '5', '6', 'B'},
  {'1', '2', '3', 'C'},
  {'C', '0', '#', 'D'}
};
byte rowPins[rows] = {9, 8, 7, 5};                                    //connect to the row pinouts of the keypad
byte colPins[cols] = {10, 11, 12, 13};                                //connect to the column pinouts of the keypad

GPRS gprs(PIN_TX, PIN_RX, BAUDRATE);                                  //RX,TX,BaudRate
Keypad customKeypad(makeKeymap(key), rowPins, colPins, rows, cols);   //initialize an instance of class NewKeypad

//#define passwordsize 5
//char code[passwordsize];
//char password[passwordsize] = "1234";
char* password = "5566";
int currentposition = 0;

void setup()
{
  myservo.attach(6);                                                  //Servo motor connection
  lcd.begin(16, 2);
  //mySerial.begin(9600);                                             // Setting the baud rate of GSM Module (
  Serial.begin(9600);                                                 // Setting the baud rate of Serial Monitor (Arduino)
  gprs.checkPowerUp();
  Serial.begin(9600);

  while (!gprs.init())
  {
    delay(1000);
    Serial.println("Initialization failed!");
  }

  while (!gprs.isNetworkRegistered())
  {
    delay(1000);
    Serial.println("Network has not registered yet!");
  }

  Serial.println("gprs initialize done!");
  Serial.println("start to send message ...");
}

void loop()
{
  if (currentposition == 0)
  {
    displayscreen(); // for activate display.
  }

  int l ;
  char code = customKeypad.getKey();
  if (code != NO_KEY)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("PASSWORD:");
    lcd.setCursor(7, 1);
    lcd.print(" ");
    lcd.setCursor(7, 1);
    for (l = 0; l <= currentposition; ++l)
    {
      lcd.print("*");
      // keypress();
    }

    if (code == password[currentposition])
    {
      ++currentposition;
      if (currentposition == 4)
      {
        unlockdoor();
        currentposition = 0;
      }
    }

    else if (code != password[currentposition])
    {
      ++currentposition;
      if (currentposition == 4)
      {
        incorrect();
        currentposition = 0;
      }
    }
  }
}

//------------------ Function 1- OPEN THE DOOR--------------//

void unlockdoor()
{
  // delay(900);
  lcd.setCursor(0, 0);
  lcd.println(" ");
  lcd.setCursor(1, 0);
  lcd.print("Access Granted");
  lcd.setCursor(4, 1);
  lcd.println("WELCOME!!");
  lcd.setCursor(15, 1);
  lcd.println(" ");
  lcd.setCursor(16, 1);
  lcd.println(" ");
  lcd.setCursor(14, 1);
  lcd.println(" ");
  lcd.setCursor(13, 1);
  lcd.println(" ");

  for (pos = 180; pos >= 0; pos -= 5)                     // open the door
  {
    myservo.write(pos);
    delay(5);
  }
  delay(1000);

  delay(1000);
  counterbeep();

  delay(1000);

  for (pos = 0; pos <= 180; pos += 5)                     // close the door
  { // in steps of 1 degree
    myservo.write(pos);
    delay(15);

    currentposition = 0;
    lcd.clear();
    displayscreen();
  }
}

//--------------------Function 2- Wrong code--------------//

void incorrect()
{
  delay(500);
  lcd.clear();
  lcd.setCursor(1, 0);
  lcd.print("CODE");
  lcd.setCursor(6, 0);
  lcd.print("INCORRECT");
  lcd.setCursor(15, 1);
  lcd.println(" ");
  lcd.setCursor(0, 1);
  lcd.println("TRY AGAIN");
  lcd.setCursor(13, 1);
  lcd.println(" ");

  SendMessage();
  delay(3000);
  lcd.clear();
  displayscreen();
}
//-------Function 3 - CLEAR THE SCREEN--------------------/
void clearscreen()
{
  lcd.setCursor(0, 0);
  lcd.println(" ");
  lcd.setCursor(0, 1);
  lcd.println(" ");
  lcd.setCursor(0, 2);
  lcd.println(" ");
  lcd.setCursor(0, 3);
  lcd.println(" ");
}

//------------Function 4 - DISPLAY FUNCTION--------------------//
void displayscreen()
{

  lcd.setCursor(0, 0);
  lcd.println("ENTER THE CODE");
  lcd.setCursor(1 , 1);
  lcd.println("TO OPEN DOOR!!");
}

//--------For Sending Password------------ /
void SendMessage()
if (gprs.sendSMS(PHONE_NUMBER, MESSAGE)) {                  //define phone number and text
  mySerial.print("Send SMS Succeed!\r\n");
} else {
  mySerial.print("Send SMS failed!\r\n");
}

//--------------Function 5 - Count down------------------//
void counterbeep()
{
  delay(1200);
  lcd.clear();
  lcd.setCursor(2, 15);
  lcd.println(" ");
  lcd.setCursor(2, 14);
  lcd.println(" ");
  lcd.setCursor(2, 0);
  delay(200);
  lcd.println("GET IN WITHIN:::");
  lcd.setCursor(4, 1);
  lcd.print("5");
  delay(200);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN:");
  delay(1000);
  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN:");
  lcd.setCursor(4, 1); //2
  lcd.print("4");
  delay(100);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN:");
  delay(1000);

  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN:");
  lcd.setCursor(4, 1);
  lcd.print("3");
  delay(100);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN:");
  delay(1000);

  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN:");
  lcd.setCursor(4, 1);
  lcd.print("2");
  delay(100);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN:");
  delay(1000);

  lcd.setCursor(4, 1);
  lcd.print("1");
  delay(100);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.println("GET IN WITHIN::");

  delay(1000);
  delay(40);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("RE-LOCKING");
  delay(500);
  lcd.setCursor(12, 0);
  lcd.print(".");
  delay(500);
  lcd.setCursor(13, 0);
  lcd.print(".");
  delay(500);
  lcd.setCursor(14, 0);
  lcd.print(".");
  delay(400);
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("LOCKED!");
  delay(440);
}

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