Compilation error: 'POSITIVE' was not declared in this scope

Here is the code:

#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <string.h>

#define SS_PIN 10
#define RST_PIN 9

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
int beepTime = 2700;
int currentNum;
int StartPmoney = 200;
int piezoPin = 1;
int card1;
int card2;
int card3;
int card4;
int card5;
int card6;
int interSt;
int lineSt = 0;
int Step=0;
byte i = 0;
byte data_count = 0; 
char customKey;
String currentCard;
String clearTr = "C";
String Data;
String firstCh;
String content= "";
String content2="";
String cardNum="";
const byte ROWS  = 4;
const byte COLS = 4;


char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', '+'},
  {'4', '5', '6', '-'},
  {'7', '8', '9', 'E'},
  {'*', '0', '#', 'C'}
};

byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

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

void setup() {
  
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  lcd.begin(16,2); 
  lcd.print("Auto Monopoly");
  lcd.setCursor(0,1);
  lcd.print("by Kladogenis P.");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0,1);
  

}

void loop() {
   

  noTone(piezoPin);

  customKey = customKeypad.getKey(); //shortening the getKey function
  Data = customKey;   
  
  if(Step==0){
   
 
    
     
    
    getCard();                                                                  //main loop <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                                                    
    receiveNum();
  }
  else if(Step==1){
     
    lcd.setCursor(0,0);
    lcd.print("Swipe");
    lcd.setCursor(0,1);
    lcd.print("second card");
    intSec();
      
  }
    
    
 
    
   
    
  

  if(Data == clearTr)               //clear with D
    {
     
     lineSt=0;
     clear();
     firstCh="";
      }


}



void receiveNum(){
  
   if (customKey){          //printing character to lcd
     
     
     lcd.setCursor(data_count,lineSt);
     Data = customKey; 
  
     
     lcd.print(Data);
     if(Data == "-"){
      tone(piezoPin, 500);
     }
     else if(Data == "+"){
      tone(piezoPin, 2500);
     }
     else{
      tone(piezoPin, beepTime);
      
     }
     delay(100);
     if(Data == "#"){
       noTone(piezoPin);
       clear();
       lcd.setCursor(0,0);
       
       GiveST();
       Data="";
       clear();
       lcd.setCursor(0,0);
       lcd.print("200$ granted");
       delay(2000);
       clear();
       lcd.setCursor(0,0);
     }
     if(Data == "*"){
      noTone(piezoPin);
      card1=1500;
      card2=1500;
      card3=1500;
      card4=1500;
      card5=1500;
      card6=1500;
      
      Data="";
      
      
      clear();
      lcd.setCursor(0,0);
      lcd.print("1500$ to each");
      delay(3000);
      clear();
      lcd.setCursor(0,0);

     }
    if(Data == "E"){
      currentNum=firstCh.toInt();
      noTone(piezoPin); 
      clear();
      everyPl();
      clear();
       lcd.setCursor(0,0);
       lcd.print(currentNum);
       lcd.print("$ granted to");
       lcd.setCursor(0,1);
       lcd.print("every player");
       delay(2000);
       clear();
       lcd.setCursor(0,0);
       Data="";
     }
     Serial.print("current:");
     Serial.println(currentNum);
     addMoney();
     minMoney();
      
     data_count++; 
     
     firstCh.concat(Data);
     
     
     
     
     if(data_count== 16){
         
         lineSt++;
         data_count=0;
         }
         
     
    
   
    }
    else{
      noTone(piezoPin);
    }
}

void clear(){                      //clear void
   lcd.clear();
   data_count=0;
   
   
      }

void getCard(){
  
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  
    tone(piezoPin, beepTime);
    delay(100);
    noTone(piezoPin);
    
  
  content="";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }

  
  content.toUpperCase();
 
    if(Step==0){
     displayCard();
  }
 
        
}

void addMoney(){
 
       if(Data == "+"){
        currentNum=firstCh.toInt();
        noTone(piezoPin);
        
        clear();
        interSt=1;
        if (content.substring(1) == "03 3D 88 1B"){
          card1=card1+currentNum;
          
          lcd.print("card1:");
          lcd.println(card1);
          delay(2000);
          clear();
         
          Step=1;
          return;
        }
        else if(content.substring(1) == "FC 2F E7 C0"){
          card2=card2+currentNum;
          
          lcd.print("card2:");
          lcd.println(card2);
          delay(2000);
          clear();
          
                    Step=1;

          return;
        }
        else if(content.substring(1) == "9E FB 67 2D"){
          card3=card3+currentNum;
          
          lcd.print("card3:");
          lcd.println(card3);
          delay(2000);
          clear();
          
                    Step=1;

          return;
        }
        else if(content.substring(1) == "2C 61 EF C0"){
          card4=card4+currentNum;
          
          lcd.print("card4:");
          lcd.println(card4);
          delay(2000);
          clear();
        
                    Step=1;

          return;
        }
        else if(content.substring(1) == "DE 08 CE 7A"){
          card5=card5+currentNum;
          
          lcd.print("card5:");
          lcd.println(card5);
          delay(2000);
          clear();
          Step=1;
          return;
        }
        else if(content.substring(1) == "2E 4B A7 7B"){
          card6=card6+currentNum;
          
          lcd.print("card6:");
          lcd.println(card6);
          delay(2000);
          clear();
          Step=1;
          return;
        }
        else{
          noTone(piezoPin);
          lcd.print("No card found");
          delay(2000);
          clear();
          content="";
          currentNum=0;
          return;
        }
        
        
     }
}

void minMoney(){
  
  if(Data == "-"){
        currentNum=firstCh.toInt();
        noTone(piezoPin);
        clear();
        interSt=0;
        if (content.substring(1) == "03 3D 88 1B"){
          card1=card1-currentNum;
          
          lcd.print("card1:");
          lcd.println(card1);
          delay(2000);
          clear();
          
                    Step=1;

          return;
        }
        else if(content.substring(1) == "FC 2F E7 C0"){
          card2=card2-currentNum;
          
          lcd.print("card2:");
          lcd.println(card2);
          delay(2000);
          clear();
          
                    Step=1;

          return;
        }
        else if(content.substring(1) == "9E FB 67 2D"){
          card3=card3-currentNum;
          
          lcd.print("card3:");
          lcd.println(card3);
          delay(2000);
          clear();
          
                    Step=1;

          return;
        }
        else if(content.substring(1) == "2C 61 EF C0"){
          card4=card4-currentNum;
          
          lcd.print("card4:");
          lcd.println(card4);
          delay(2000);
          clear();
          Step=1;
          return;
        }
        else if(content.substring(1) == "DE 08 CE 7A"){
          card5=card5-currentNum;
          
          lcd.print("card5:");
          lcd.println(card5);
          delay(2000);
          clear();
          
                    Step=1;

          return;
        }
        else if(content.substring(1) == "2E 4B A7 7B"){
          card6=card6-currentNum;
          
          lcd.print("card6:");
          lcd.println(card6);
          delay(2000);
          clear();
          Step=1;
          return;
        }
        else{
          noTone(piezoPin);
          lcd.print("No card found");
          delay(2000);
          clear();
          content="";
          return;
        }
        
     
     }
}

void intSec(){
  content="";
  
  getCard();
  
  
  if (content==""){
    return;
  }
  
       Serial.print("boom");
       if (content.substring(1) == "03 3D 88 1B"){
          if(interSt==1){
            card1=card1-currentNum;
            
          }
          else{
            card1=card1+currentNum;
            
          }
          Step=0;
        }
      if(content.substring(1) == "FC 2F E7 C0"){
          if(interSt==1){
            card2=card2-currentNum;
          }
          else{
            card2=card2+currentNum;
          }
          Step=0;
        }
        if(content.substring(1) == "9E FB 67 2D"){
          if(interSt==1){
            card3=card3-currentNum;
            
          }
          else{
            card3=card3+currentNum;
          }
          Step=0;
        }
        if(content.substring(1) == "2C 61 EF C0"){
          if(interSt==1){
            card4=card4-currentNum;
          }
          else{
            card4=card4+currentNum;
          }
          Step=0;
        }
       if(content.substring(1) == "DE 08 CE 7A"){
          if(interSt==1){
            card5=card5-currentNum;
          }
          else{
            card5=card5+currentNum;
          }      
          Step=0;    
        }
         if(content.substring(1) == "2E 4B A7 7B"){
         if(interSt==1){
            card6=card6-currentNum;
            
          }
          else{
            card6=card6+currentNum;
            
          }
          Step=0;
        }
       if(content.substring(1) =="2B 63 BC 0D"){
           Step=0;
           lcd.setCursor(0,0);
           lcd.print("transaction");
           lcd.setCursor(0,1);
           lcd.print("confirmed with the ");
        }
        else{
          lcd.print("error");
          cardNum="";
           
          Step=0;
          
        }
        
        
        clear();
        lcd.clear();
        displayCard();
        firstCh="";
       
  
}

void displayCard(){
    noTone(piezoPin);
    if(content.substring(1) == "03 3D 88 1B"){
    lcd.print("Card1:");
    lcd.print(card1);
    lcd.print("$");
    
  }
  if(content.substring(1) == "FC 2F E7 C0"){
    lcd.print("Card2:");
    lcd.print(card2);
    lcd.print("$");
    
  }
  if(content.substring(1) == "9E FB 67 2D"){
    lcd.print("Card3:");
    lcd.print(card3);
    lcd.print("$");
   
  }
  if(content.substring(1) == "2C 61 EF C0"){
    lcd.print("Card4:");
    lcd.print(card4);
    lcd.print("$");
   
  }
  if(content.substring(1) == "DE 08 CE 7A"){
    lcd.print("Card5:");
    lcd.print(card5);
    lcd.print("$");
    
  }
  if(content.substring(1) == "2E 4B A7 7B"){
    lcd.print("Card6:");
    lcd.print(card6);
    lcd.print("$");
    
  }
  if(content.substring(1) == "2B 63 BC 0D"){
    lcd.print("Banker Key");
    lcd.setCursor(0,1);
    lcd.print("detected");
    
    
  }
  delay(2000);
  clear();
  lcd.setCursor(0,0);
}
void GiveST (){
 if (content.substring(1) == "03 3D 88 1B"){
          card1=card1+StartPmoney;
          
          lcd.print("card1:");
          lcd.println(card1);
          delay(2000);
          clear();
          
            
          return;
        }
        else if(content.substring(1) == "FC 2F E7 C0"){
          card2=card2+StartPmoney;
          
          lcd.print("card2:");
          lcd.println(card2);
          delay(2000);
          clear();
          
                   

          return;
        }
        else if(content.substring(1) == "9E FB 67 2D"){
          card3=card3+StartPmoney;
          
          lcd.print("card3:");
          lcd.println(card3);
          delay(2000);
          clear();
          
               

          return;
        }
        else if(content.substring(1) == "2C 61 EF C0"){
          card4=card4+StartPmoney;
          
          lcd.print("card4:");
          lcd.println(card4);
          delay(2000);
          clear();
         
          return;
        }
        else if(content.substring(1) == "DE 08 CE 7A"){
          card5=card5+StartPmoney;
          
          lcd.print("card5:");
          lcd.println(card5);
          delay(2000);
          clear();
          
                

          return;
        }
        else if(content.substring(1) == "2E 4B A7 7B"){
          card6=card6+StartPmoney;
          
          lcd.print("card6:");
          lcd.println(card6);
          delay(2000);
          clear();
        
          return;
        }
        else{
          noTone(piezoPin);
          lcd.print("No card found");
          delay(2000);
          clear();
          content="";
          return;
        }
        
        
     }

void everyPl(){
   if (content.substring(1) == "03 3D 88 1B"){
          card1=card1-currentNum;
          card2=card2+currentNum;
          card3=card3+currentNum;
          card4=card4+currentNum;
          card5=card5+currentNum;
          card6=card6+currentNum;
          lcd.print("card1:");
          lcd.println(card1);
          delay(2000);
          clear();
          
            
          return;
        }
        else if(content.substring(1) == "FC 2F E7 C0"){
          card1=card1+currentNum;
          card2=card2-currentNum;
          card3=card3+currentNum;
          card4=card4+currentNum;
          card5=card5+currentNum;
          card6=card6+currentNum;
          
          lcd.print("card2:");
          lcd.println(card2);
          delay(2000);
          clear();
          
                   

          return;
        }
        else if(content.substring(1) == "9E FB 67 2D"){
          card1=card1+currentNum;
          card2=card2+currentNum;
          card3=card3-currentNum;
          card4=card4+currentNum;
          card5=card5+currentNum;
          card6=card6+currentNum;
          
          lcd.print("card3:");
          lcd.println(card3);
          delay(2000);
          clear();
          
               

          return;
        }
        else if(content.substring(1) == "2C 61 EF C0"){
         card1=card1+currentNum;
          card2=card2+currentNum;
          card3=card3+currentNum;
          card4=card4-currentNum;
          card5=card5+currentNum;
          card6=card6+currentNum;
          
          lcd.print("card4:");
          lcd.println(card4);
          delay(2000);
          clear();
         
          return;
        }
        else if(content.substring(1) == "DE 08 CE 7A"){
          card1=card1+currentNum;
          card2=card2+currentNum;
          card3=card3+currentNum;
          card4=card4+currentNum;
          card5=card5-currentNum;
          card6=card6+currentNum;
          
          lcd.print("card5:");
          lcd.println(card5);
          delay(2000);
          clear();
          
                

          return;
        }
        else if(content.substring(1) == "2E 4B A7 7B"){
          card1=card1+currentNum;
          card2=card2+currentNum;
          card3=card3+currentNum;
          card4=card4+currentNum;
          card5=card5+currentNum;
          card6=card6-currentNum;
          
          lcd.print("card6:");
          lcd.println(card6);
          delay(2000);
          clear();
        
          return;
        }
        else{
          noTone(piezoPin);
          lcd.print("No card found");
          delay(2000);
          clear();
          content="";
          return;
        }
}

And this is the error message:

error: 'POSITIVE' was not declared in this scope
 LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
                                                     ^~~~~~~~

exit status 1

Compilation error: 'POSITIVE' was not declared in this scope

the line throwing the error:

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

The compiler is quite right. POSITIVE is not declared in the scope in which it is used. In face, it does not appear to be declared anywhere in the sketch

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

Where did you borrow that line of code from and which of the many LiquidCrystal_I2C libraries are you using ?

What are you trying to do? Can you post a schematic of your project? Your declarations are in error on the hardware side.

it is from his tutorial: https://www.instructables.com/Monopoly-RFID-Automated-Bank/

and the Liquid cryctal library is "LiquidCrystal Arduino library for the DFRobot I2C LCD displays"

Are you using the LCD library that the Instructable links to ?

ok now i get no reason just


exit status 1

Compilation error: exit status 1

With what code and library?

Is that the whole error message copied from the IDE using the "COPY ERROR MESSAGES" button ?

yes

this is the one I'm using GitHub - arduino-libraries/LiquidCrystal: Liquid Crystal Library for Arduino

Try some other libraries. There are many with the same or similar names.

This is one of the problems with blindly copying someone else's code and assuming it will work, especially with Instructables, which has non-existent quality control. Users are not allowed to post complaints.

1 Like

Use this library https://github.com/fmalpartida/New-LiquidCrystal

You may need to delete any other libraries that have the LiquidCrystal_I2C.h header file, otherwise the compiler may choose the wrong library.

Seems to be very popular this weekend, 4th time I've seen this same error in the last day or so.

1 Like

POSITIVE is backlight polarity. See line 65, 80, 102, 146

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