LCD weird characters being displayed

I get some kind of display error with my LCD. It is programmed as a clock.
The error does not occur at once - some times it takes several hours or days

I’ve attached an image of it.
Do any of you know what this might be?

This is my code for displaying time:

  if (previousSec != now.second()) {
    previousSec = now.second();
    delay(100);


    if (setAlarmState == 0 & setCalibState == 0) {
      lcd.clear();
      if(now.hour() < 10) {
        lcd.print("0");
        lcd.print(now.hour(), DEC);
      } 
      else {
        lcd.print(now.hour(), DEC);
      }
      lcd.print(":");
      if(now.minute() < 10) {
        lcd.print("0");
        lcd.print(now.minute(), DEC);
      } 
      else {
        lcd.print(now.minute(), DEC);
      }
      lcd.print(":");
      if(now.second() < 10) {
        lcd.print("0"); 
        lcd.print(now.second(), DEC);
      } 
      else {
        lcd.print(now.second(), DEC);

      }
      if (alarmOn == 1 & alarm != 1) {
        lcd.print("* ");

        lcd.print(analogRead(A1));
      }

      if (alarm == 1) {
        lcd.print(" ");
          lcd.print(average);

        
      }

    }
  }

You haven't given us very much information.

For starters we need to see all of the code.

Don

You seem to be missing a second & in both of these.

if (setAlarmState == 0 & setCalibState == 0) { if (alarmOn == 1 & alarm != 1)

I dont think these are doing what you want them to do, but it may not be the issue at all, unless you post your full code.

The times I had this problem was because I was incorrectly wiring a parallel LCD.

You seem to be missing a second & in both of these.

Quote if (setAlarmState == 0 & setCalibState == 0) { if (alarmOn == 1 & alarm != 1)

I dont think these are doing what you want them to do, but it may not be the issue at all, unless you post your full code.

As mentioned: if (setAlarmState == 0 && setCalibState == 0) { if (alarmOn == 1 && alarm != 1)

The error does not occur at once - some times it takes several hours or days

I had a similar problem, turned out to be a bad display.

Thanks for your answers!

I'll try with a new display, though this is the second one where I am seeing this error.

Thanks for pointing out the part about the & sign. It does work however, the reference says the single & is a BITWISE and. (Though it wasn't my intention to use this)

So wait, this is already the second one or your going to get a second one? If this is the second one then it is unlikely it is the display itself but maybe an issue with the way its wired. Another thing it could be, (but I doubt it), is memory. Maybe the memory is being filled. But then again you said, it could be hours or even days before this happens, so again, I doubt its the memory.