After 20-25secs , the loop() slows down

Hi everyone.

I’m experimenting with the Arduino’s world (my boss gave me this project to analize and develop) and i’m having a few issues that i don’t know how to solve.

I have an Arduino UNO, connected with an lcd (16x2) and a RC522 to read RFID’s tags.

When it starts, i see all OK, the LCD shows the info i need, refreshing every 0.1sec, BUT, after 25secs, the lcd screen starts to refresh every 1 sec and if i try to scan the tag, it does nothing.

My guess is that the loop() is getting slow by something, but not sure by what (maybe the wires?).

Sorry for my poor knowledge, i’m starting with this!

#include <LiquidCrystal.h> // Incluye la Libreria LiquidCrystal





LiquidCrystal lcd(1, 2, 4, 5, 6, 7); 



#include <SPI.h>
#include <MFRC522.h>


#define SS_PIN 10
#define RST_PIN 8
#define greenLed A1      
#define redLed A2      

MFRC522 mfrc522(SS_PIN, RST_PIN);   
byte Heart[] = {
   B00000,
  B01111,
  B00111,
  B00011,
  B00000,
  B00000,
  B00000,
  B00000
};
byte Bell[] = {
  B00000,
  B11100,
  B11110,
  B11110,
  B11111,
  B11111,
  B00011,
  B00001
};
byte Alien[] = {
   B00111,
  B01110,
  B11111,
  B00000,
  B00000,
  B10101,
  B00000,
  B00000
};
byte Check[] = {
  B00000,
  B00111,
  B01111,
  B01111,
  B11111,
  B11111,
  B11000,
  B10000
};
byte Speaker[] = {
 B00000,
  B11110,
  B11100,
  B11000,
  B00000,
  B00000,
  B00000,
  B00000
};
byte Sound[] = {
   B11111,
  B11011,
  B01110,
  B00100,
  B00000,
  B00000,
  B11111,
  B00000
};
byte Sound2[] = {
   B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B11111,
  B00000
};


void soft_reset() {
 asm volatile ("  jmp 0"); 
}

String content= "";
  byte letter;
  
void lectura()
{
    
  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));
  }
 // Serial.println();
 // Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "04 17 88 72 5E 5C 81") //Authorised UID
  {
    lcd.clear();
    lcd.setCursor(0,0);        
    lcd.print("BERETTA SN XJA2F");
   
    //Serial.println("Authorized access");
    //Serial.println();
   
  //buzzer
 
  analogWrite(3,20);
  delay(100);
  analogWrite(3,0);

  // led
  digitalWrite(greenLed, HIGH);  
   
  delay(2000);
  digitalWrite(greenLed, LOW);    
 
  }
 else{
  lcd.clear();
    lcd.print("ERROR  ");
    // led
    analogWrite(3,20);
    digitalWrite(redLed, HIGH);
 
    delay(500);
    analogWrite(3,0);
    analogWrite(3,20);
   
    analogWrite(3,0);
  delay(1000);            
  digitalWrite(redLed, LOW);    
 
   
  }  
  soft_reset();


  // Halt PICC
mfrc522.PICC_HaltA();
// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();
  }


void setup() {  
  lcd.begin(16,2); // Inicializa la interface para el LCD screen, and determina sus dimensiones (ancho y alto) del display
  pinMode(greenLed,OUTPUT);  
  pinMode(redLed,OUTPUT);
  SPI.begin();      // Initiate  SPI bus  
  mfrc522.PCD_Init();   // Initiate MFRC522

   lcd.begin(16, 2);
  // Create a new characters:
  lcd.createChar(0, Heart);
  lcd.createChar(1, Bell);
  lcd.createChar(2, Alien);
  lcd.createChar(3, Check);
  lcd.createChar(4, Speaker);
  lcd.createChar(5, Sound);
  lcd.createChar(6, Sound2);


  
}

//int release=0;

void loop() {
 
  //delay(500);
   lcd.clear();
  // Print a message to the lcd:
  lcd.setCursor(7,0);
  lcd.print("Escanear");
  lcd.setCursor(7,1);
  lcd.print("elemento:");
 lcd.setCursor(0,0);
  lcd.write(byte(0));
 
  lcd.write(byte(1));
 
  lcd.write(byte(2));
 
  lcd.write(byte(3));
 
  lcd.write(byte(4));

  lcd.setCursor(2, 1);
  lcd.write(byte(5));

  lcd.setCursor(1, 2);
  lcd.write(byte(6));

  lcd.setCursor(1, 3);
  lcd.write(byte(6));

  lcd.setCursor(3, 1);
  lcd.write(byte(6));
  // Look for new cards
  if (mfrc522.PICC_IsNewCardPresent())
  {    
      if (mfrc522.PICC_ReadCardSerial())
      {
          lectura();
      }
  }

 // Halt PICC
mfrc522.PICC_HaltA();
// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();


 }

First suspect would be your use of String.

Try commenting out all references to String(s) or try changing your code to use standard NULL-terminated character-strings and see what happens.