remember Value after reset/power off

Hi guys
I need some help here…
I want my Arduino to remember the times a event happened.
Let’s say I push a button and it’s counting up each time the button has been pressed, but after certain times of use it will do another function.
How can I program Arduino to remember the times it has been pressed including after power off?
Thanks

EEPROM

the specs of the Adafruit I2C FRAM seem sweet!

#include "Adafruit_FRAM_I2C.h"

Have used with good results.

EEPROM library

Now if you are frequently updating the data you wish to remember over a power cycle, then if you are already using a RTC to keep time - as you would need to do - you write the data into the battery-backed RAM on the RTC which has no limit to write cycles.

Hi again
Thanks for all the info.
Using rtc is only for the one power cycle correct? After it would erase.
I have tested to write to the eemprom itself and works eemprom.write(0,value)
Works good but have also read about leveled
Degradation...how does this work?
Thanks

The RTC BB-RAM is there to use it in whatever way you like (but not all RTCs have it). It does whatever you program to do with it.

You can write the BB-RAM as often as you like, just like the RAM in your PC, you cannot wear it out.

So if you want to ensure your saved time is accurate to the nearest second, you can write the value every second. Or ten times a second.

But a million writes to EEPROM is expected to "wear" it and it may fail. A million seconds is just 11½ days.