I have been starting my adventure with LCD screen today. I wanted to add some lcd functions to my existing sketch and after that problem appered.
When i try to write something on LCD in void loop, program compile the sketch but nothing displays in LCD screen. When I was writing lcd.print("something") in void setup, everything is ok. LCD displays what I want. Problem is in void loop.
When you post code on the forum, please make a habit of using the code tags "#" button.
click the MODIFY button in the upper right of the post window.
Highlight all you code.
click the "#" CODE TAGS button on the toolbar above just to the left of the QUOTE button.
click SAVE (at the bottom).
I think you need to learn how to use the lcd.SetCursor(0,0);
I have never used, or seen anybody else use lcd.display() or lcd.nodisplay() before and I really don't understand why you are using it here.
That command seems to allow you to either display a specific message or not display that same message without the need to re-write it each time you want to display it.
In your case you are immediately writing a new message immediately after restoring the old one but, as was implied in the preceding answer, the new message is appended to the old one. So at least at some point you are going to be sending information to locations that are not visible on your 16x2 display.