LCD have a very slow update when sending instructions

Hello guys!

I have a program that when i send a question 5 times a second to a sensor I get a string value and the program then write a certain part of the received string on a ordinary HD44780 20x4 LCD and it is all communicating with Tx and Rx.

Im using the Mega 2560

This is a direct part of the main code that write something to the LCD:

#include <LiquidCrystal.h>

LiquidCrystal lcd(40, 42, 28, 26, 24, 22);

String value;               // Somewhere to save sting data to be able to mess with later on

void setup() {


  lcd.begin(20, 4);


void loop() {

while (Serial.available());          // Is there any serial data in the buffer?
                                             // If there is then continue on
                                             // If there is no data then just loop this first
                                             // row and don´t print anything what so ever

    value = Serial.readString();    // Where to save the string data
                                              // Read data and save it here   

       lcd.setCursor(8, 0);             

    for (int mod = 7; mod < 14; mod++) {  // Start at character 7 and step forward to character 14

       lcd.write(value[mod]);       // Take characters in string "value" and do
                                            // "int mod" on the string which is; take full string but take only 
                                            // the characters between character 7 and 14 and then print
                                            // only these on the LCD and then go back to see for new data

When I write something in serial monitor, I see that the Arduino receives it right away with the Rx and Tx leds but the text will not show up on the LCD at all until a whole 1.3 seconds later!

What is this?

The Arduino will of course not take any 1.3 sec to execute the program but the other hand neither should even the crappiest LCD do after it got the instructions, so what is going on?

I have tested to put the LCD both as a 20x2 as well as 16x1 and everything in between but no difference. As seen so is it set for 4-bit but it wouldnt matter either as I see it.

I have some few questions about the code as well but I take that in another thread since it doesnt have anything to do with the LCD.

value = Serial.readString(); Slow, you say?

Dont get it, meaning?

Might mention that I only two week ago starting to learn C, which is hardly even scratching the surface that is, but I have a little hard time to believe Serial.readString would take half an eternity to read only 17 characters from the serial port so Im obviously miss something here?

How long is the timeout for readString? (I genuinely don't know - I don't use it)

It is standardized to 1 sec and I was sure data was overwritten by any next data that came and since that came 5 times a second the timeout was more then plenty and if it got to timeout it would stop or such was my thoughs.

I have now however understood this is not the case.

It seem, if i understand it right, that it gather whatever data there is and hold this for one second (or whatever the timeout is set to) until it check for new data, sigh.

Tried 50 ms timeout and it seem to work as supposed now.

Thanks for pointing it out and thanks for the help!