save counter values in EEPROM arduino uno

Hi guys
latly im working with simple project that consist of save value from counter in EEPROM i check youtube and other website but i didn t anything good so does anybody have an idea that might be helpful
and thanks

Have done similar here.

Write the counter only at certain times as there are a limited number of times EEPROM can be written to.

Suggest you only write the counter at power down time.

Edit
Some reading:
https://forum.arduino.cc/index.php?topic=547472.0

this my program i didn t understand you very well so if can tell me what i have to change

COMP.ino (1.1 KB)

There is an example included here on saving at power-fail time.
https://forum.arduino.cc/index.php?topic=547472.0

thx i will try and get u the result when i finish

FYI
An EEPROM location can be written to about 100,000 times only !

If you constantly write to the same location, it will eventually fail.