Trying to show multiple texts

I'm learning Arduino and this one issue is has me stumped. I'm trying to have it show an greeting message then clear and show another message. I can't figure out what else I need to add to do that.

Here is my code:

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
lcd.begin(16, 2);

}

void loop() {
lcd.setCursor(2,0);
lcd.print("Good Evening");
lcd.setCursor(5,1);
lcd.print("Master");
delay(2000);
lcd.clear();
delay(1000);
lcd.setCursor(1,0);
lcd.print("Please enter");
lcd.setCursor(3,1);
lcd.print("your password: ");
}

Welcome to the forum

Your topic was MOVED to its current forum category as it is more suitable than the original

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

IF that is all you need, then put ALL that code in the setup() function and it will be done only once.

does any text appear on the display?

Power on should display a row of blocks. if you can't see that, adjust the contrast pot on the I2C board. If you don't HAVE an I2C board GET ONE.

You can edit your original post to include tags by using the little pencil :pencil2:

The problem is that you have the code in loop...

void loop()
{
  // Display first message 
  // delay for 2 seconds
  // clear the screen
  // delay for 1 second
  // Display second message
}

So immediately after displaying the second message, the loop begins again... and the first thing it does is display the first message again... overwriting the second message almost immediately, so you never see it.

Add another delay(2000) after the second message and you will be able to see more clearly what is happening.

That worked. Thank you!

Mark your post as solved and learn about code tags and the edit pencil :pencil2:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.