store data from a push button counter

I need help with a code to store counts on SD card from a push button without filling up memory card with unnecessary data between button pushes. Every code I come up with either doesn't store data or continuously stores data between button pushes.

Hi, welcome to the forum.

You have to detect the change of the button. That means you have to use a variable that remembers the previous state of the button, and if the new state is different, the button has just been pressed or released.

Do you use some kind of debounce for the button ?

Can you show you sketch (between code tags) ?