lcd 16*2 char issue

Hi dear

I used one LCD 16 * 2 char in my Arduino project , but for show different messages in LCD , I use delay() function to do this , but the micro have to Waite until delay() function time finished and this is not good for me when Micro (Arduino) must do some other tasks in same time. but its have to just show some messages in LCD in that period of time and do nothing for another tasks, What other solution is exist for set time for LCD but micro do other tasks ??

Have a look at the blink without delay example in the IDE

You could insert the following code at the beginning of your void loop():

if(millis()> last_update_time+your_delay){
    //update lcd
    last_update_time=millis();
}

GreenSmurf: You could insert the following code at the beginning of your void loop()

sp."You could insert the following code at the beginning of your loop() function".

Of course, there's a little more to it than that, which is why it is better to look at the example in the IDE

hzajkani: Hi dear

I used one LCD 16 * 2 char in my Arduino project , but for show different messages in LCD , I use delay() function to do this , but the micro have to Waite until delay() function time finished and this is not good for me when Micro (Arduino) must do some other tasks in same time. but its have to just show some messages in LCD in that period of time and do nothing for another tasks, What other solution is exist for set time for LCD but micro do other tasks ??

Give this a try:

void showDifferentMessages()
{
  byte whichMessage=(millis()/1000)%3;
  lcd.setCursor(0,0);
  if(whichMessage==0) lcd.print("Hello");
  else if(whichMessage==1) lcd.print("World");
  else lcd.print(millis()/000);
}

When calling "showDifferentMessages();" from your loop() function infinitely, you will see a changing message on the lcd, which changes each second between -"Hello" - "World" - seconds since power-on/reset

AWOL: sp."You could insert the following code at the beginning of your loop() function".

Of course, there's a little more to it than that, which is why it is better to look at the example in the IDE

Of course, but I think my example is enough to understand the basic concept.

GreenSmurf: Of course, but I think my example is enough to understand the basic concept.

No, it will simply confuse a noob, because it won't compile.

jurs:
Give this a try:

void showDifferentMessages()

{
 byte whichMessage=(millis()/1000)%3;
 lcd.setCursor(0,0);
 if(whichMessage==0) lcd.print(“Hello”);
 else if(whichMessage==1) lcd.print(“World”);
 else lcd.print(millis()/000);
}




When calling "showDifferentMessages();" from your loop() function infinitely, you will see a changing message on the lcd, which changes each second between
-"Hello"
- "World"
- seconds since power-on/reset

No idea what the last statement will print, but dividing by zero should print ‘infinty’ :wink:

sterretje: No idea what the last statement will print, but dividing by zero should print 'infinty' ;)

Sorry, my mistake, the last line in my example should read:

else lcd.print(millis()/1000);

(milliseconds divided by 1000 and Not by octal triple.zero. Seems like I missed typing a '1'where it should appear.