Slight blinking of contrast when clearing and updating

Hi all. I have noticed in my program you notice a small dip of the contrast on the LCD display I’m using every time it loops.
I am using the clear screen function at the start and a short delay at the end. I need to clear it because there might be less characters being displayed on next loop

I just adapted this simple example code to try it on another program but it does the same thing so not something in my code.

Is there any way to stop / reduce it? It is one of the ebay special Chinese 20x4 blue back-light white char versions.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);


void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);
  pinMode(3, OUTPUT);   //LCD BACKLIGHT

}

void loop() {

    // Print a message to the LCD.
  lcd.clear();
  lcd.print("hello, world!");
  digitalWrite(3, HIGH);
  
  
  delay(500);
}

I don't know about clear, is it using the hardware display clear, or is it overwriting the display content?

Usually I overwrite the old display content with spaces,
reload address, and then write the text.

If there is no change in the display length, there is no visual effect at all.

Why have you put that code in loop(). There is no need to refresh non-changing information displayed on the LCD and there is no need to keep on turning the backlight on.

When you do have a need to display changing data then you should try to avoid using the lcd.clear() function if at all possible. That function takes a relatively long time to complete and as you have noticed it also seems to cause some flicker. You are better off just clearing the required locations yourself.

Don

I don't know about clear, is it using the hardware display clear, or is it overwriting the display content?

Yes to both questions.

The lcd.clear() function invokes the LCD controller 'Clear Display' instruction.

The LCD controller 'Clear Display' instruction writes the ASCII code for a space into all 80 memory locations in the controller display memory, thus overwriting the display content.

Don

Hi, its just a bit of code I put together to test with and replicate the behaviour that I get on my main program (thermostat and multi zone temp display), which has a whole screen full of constantly changing data and possibly data length.

So if I understand correctly, one option would be to write spaces just in case the data length shortens, and then I would not have to use the clear function at all?

Thanks

So if I understand correctly, one option would be to write spaces just in case the data length shortens, and then I would not have to use the clear function at all?

Yes. Several ways to do this were covered recently, here: Arduino Forum

Don