Freezing LCD

Hello everyone. Does anyone know how can I "freeze" whatever the LCD displays after 30 seconds?
And then I am able to reset the arduino with the reset button and start over again.
I have the LCD4884.

Thank you.

I submit that all you need is timer section in the loop of your programme and lines to the effect

get timer
if timer < 31 then lcd.print (dadedah):

i.e. if the timer is over 30, it doesn’t.

I imagine the screen already clears on reset.

I "freeze" whatever the LCD displays after 30 seconds?
And then I am able to reset the arduino with the reset button and start over again.

The LCD has a built-in character buffer... it 'remembers' what is on the display until the uC gives it an update. The screen will clear when the LCD is initialized in the setup() portion of the Arduino code. So, if you just want the screen to update every 30 seconds, then use a memory variable and millis() to create a state machine withing the loop() and a reboot of the software on the arduino is Not necessary. Refer to the 'Blink Without Delay' example code.

Ray

Thank you for your answers but I'm newbie on programming and arduino. I want somehow the display update normally the screen with 500ms at the begin so i can see the measurements on the LCD and after 30 seconds the LCD will freeze so i can see the last measurements that are displayed (speed direction latitude longitude etc.) and the LCD will not update again until i will press the reset button to start over

to be more specific this is the code for the center button:

case KEY_CENTER:
originLat = lat;
originLon = lon;
lcd.LCD_write_string(0, 0, " Location Set ", MENU_HIGHLIGHT);
delay(1000);
break;

and i want when i press the center button the timer will start and after 30 seconds the display will freeze.
What code do I have to add here?

Before one of the moderators get involved: please read the 'sticky' note(s) regarding forum rules... specifically, you MUST use code-tags for sample code or the forum police will jump up and down and maybe scream! Not good.

and i want when i press the center button the timer will start and after 30 seconds the display will freeze.
What code do I have to add here?

Nick gave you one idea, I gave you another. Either will work. What we do not usually do here is write code examples for you; rather, we would prefer that you attempt to use examples provided with Arduino and examples found on the Internet and build some code for yourself. Yes, you may then need help, but that is our role.

The most basic tutorial on LCD is here:

Medium complexity tutorials are here:

And Jeremy gives a fairly good performance here:

Spend a few hours online, spend a weekend on writing some code and modifying the examples available to you. If you need more help (assistance), then come back and post what code you have crated and ask a specific question to get you back on track.

Ray

What I wrote should do what you want. You specifically mentioned the reset button, which seems fine. You could use another key to do the same job but I suggest you don’t bother for the moment.

What you are doing is running around a loop once per second and displaying a result - very normal. As I said, all you need to do is stop any further display after 30 trips. I bet you don’t even need a timer for this, you just need to count and have an “if” condition.

In setup
timer = 0

in loop

timer = timer + 1
if timer < 31 then lcd.print (dadedah); // i.e. if over 30, don’t print

I implied before that timer was some sort of clock function but here it is simply a variable. The delay command you already have suffices as the clock.

ok thank you for your answers i will try later and let you know

You are on the right track, just expand your pseudo code a little.
But before you do here are some comments:

Look at LCD as a “black box” - you write to it. Detailed knowledge as some folks suggested is really not that necessary as long as the “write “ function works. I am not saying ignore these advises, but you need to accept common coding practice – abstraction. You will have plenty of opportunities to want to learn more about LCD internals later or maybe never.
It appears to me that you are not sure how to update the LCD, but as long as you accept that the “write” function does the update for your you do not need the 500ms delay. It is taken care of inside the “write “function” ( or at least it should).
It is a good practice that anytime you interact with hardware the function which does the work returns something to indicate that it completed correctly and in an allotted time.

As a side note – there is no need to specifically “initialize” the LCD data.
Each time you write new data into it it gets overwritten, it is memory with a display. Unless of course you want to update / clear specific LCD character only.

But the LCD itself has to be initialized – for example if you want to run 8 bit LCD using only 4 bits the “default” initialization needs to be changed accordingly. Than you will need the detailed knowledge of LCD operation I was telling you initially to ignore. Life is tought.

Now for the code – addition in bold:

Event // case KEY_CENTER:
Main Loop counter initialize to 30
Main loop

originLat = lat;
originLon = lon;
** Success = lcd.LCD_write_string(0, 0, " Location Set ", MENU_HIGHLIGHT);**
if(Not Success )
** Handle Error.... **
delay(1000);
Decrement Main Loop counter
If Main Loop counter not zero
** Run Main loop**
Done
Vaclav

Thank you guys i figured out how to do it