lcd.clear is'nt working well

I connected to my board lcd screen and a rfid scanner(MFRC522) I want that when i scan the tag that registered in the code on the lcd there will be text "Welcome" and then clear it but when i do it its only adding a weird symbol after "Welcome" and the same on unregistered tags...

here is my code:

#include <RFID.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include <RFID.h>

#define SS_PIN 10
#define RST_PIN 9

RFID rfid(SS_PIN,RST_PIN);

const int rs = 1, en = 8, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int led1 = 7;
int i=1;
int led2=6;
int power = 8; 
int serNum[5];
int cards[][5] = {
 {104,102,176,121,199
}
 
};

bool access = false;

void setup(){


lcd.begin(16,2);
   Serial.begin(9600);
   SPI.begin();
   rfid.init();
   

   pinMode(led1, OUTPUT);
   pinMode(led2, OUTPUT);

   digitalWrite(led1, LOW);
   digitalWrite(led2, LOW);
   
  
}

void loop(){
   
   if(rfid.isCard()){
   
       if(rfid.readCardSerial()){
           Serial.print(rfid.serNum[0]);
           Serial.print(" ");
           Serial.print(rfid.serNum[1]);
           Serial.print(" ");
           Serial.print(rfid.serNum[2]);
           Serial.print(" ");
           Serial.print(rfid.serNum[3]);
           Serial.print(" ");
           Serial.print(rfid.serNum[4]);
           Serial.println("");
           
           for(int x = 0; x < sizeof(cards); x++){
             for(int i = 0; i < sizeof(rfid.serNum); i++ ){
                 if(rfid.serNum != cards
) {

                   
                     access = false;
                     break;
                     
                 } else {
                   
                     access = true;
                     
                 }
                 
             }
             if(access) break;
           }
          
       }
       
      if(access){
     
       digitalWrite(led1, HIGH); 
       delay(1000);
       digitalWrite(led1, LOW);
       lcd.print("Welcome");
       delay(2500);
       lcd.clear();
       
     } else {
       digitalWrite(led2, HIGH); 
       delay(1000);
       digitalWrite(led2, LOW);
        lcd.print("Tag not registered");
       delay(2500);
       lcd.clear();
               
      } 
          
   }
   
   
   
   rfid.halt();

}

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that 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 just 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.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor you will not have access to this useful tool but it's still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we're trying to read your code.

arielsho04's picture:

I connected to my board lcd screen and a rfid scanner(MFRC522) I want that when i scan the tag that registered in the code on the lcd there will be text "Welcome" and then clear it but when i do it its only adding a weird symbol after "Welcome" and the same on unregistered tags...

#include <RFID.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include <RFID.h>

#define SS_PIN 10
#define RST_PIN 9

RFID rfid(SS_PIN, RST_PIN);

const int rs = 1, en = 8, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int led1 = 7;
int led2 = 6;
int power = 8;
int serNum[5];
int cards[][5] = {
  { 104, 102, 176, 121, 199
  }
};

bool access = false;

void setup() {

  lcd.begin(16, 2);
  Serial.begin(9600);
  SPI.begin();
  rfid.init();

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);

}

void loop() {

  if (rfid.isCard()) {

    if (rfid.readCardSerial()) {
      Serial.print(rfid.serNum[0]);
      Serial.print(" ");
      Serial.print(rfid.serNum[1]);
      Serial.print(" ");
      Serial.print(rfid.serNum[2]);
      Serial.print(" ");
      Serial.print(rfid.serNum[3]);
      Serial.print(" ");
      Serial.print(rfid.serNum[4]);
      Serial.println("");
      for (int x = 0; x < sizeof(cards); x++) {
        for (int i = 0; i < sizeof(rfid.serNum); i++ ) {
          if (rfid.serNum[i] != cards[x][i]) {

            access = false;
            break;

          } else {

            access = true;

          }

        }
        if (access) break;
      }

    }

    if (access) {

      digitalWrite(led1, HIGH);
      delay(1000);
      digitalWrite(led1, LOW);
      lcd.print("Welcome");
      delay(2500);
      lcd.clear();

    } else {
      digitalWrite(led2, HIGH);
      delay(1000);
      digitalWrite(led2, LOW);
      lcd.print("Tag not registered");
      delay(2500);
      lcd.clear();

    }

  }

  rfid.halt();

}

Moderator:
@arielsho04 don't cross post threads!!
Your thread in section Other SOftware Development has been removed

Try using a different pin for the LCD 'RS' connection as pin 1 is used by the serial port.

Don

I did what you suggested (I switched between led 2 and the rs pin) and now the led is always on...

arielsho04:
I did what you suggested (I switched between led 2 and the rs pin) and now the led is always on...

If the LED is now on pin 1 then it has a conflict with the serial port (as you have seen).

You need to use an additional I/O pin, you cannot merely switch the existing ones around.

Stay away from pins 0 and 1. Don't forget that you can use the so called 'analog' pins.

Don