Go Down

Topic: Pause writing to SD card and resume in the same file (Read 395 times) previous topic - next topic

novice123

Hello,

I was wondering if it is possible to pause writing to Sd card with the help of a push button  and resume writing to the sd card (by pressing the push button again)  in the same file without creating a new file on the Sd card using SD.h library?

Thank you!

Lucario448

You can by simply not closing the file. But be careful: the library caches (buffers) data in blocks of 512 bytes before actually writting them into the card; any data that still remains only in RAM will be lost if the Arduino resets or powers off (during the pause in this case).
If the recording isn't time-critical, you can avoid this by calling flush(); you usually close the file when you're really done with it.

novice123

Can we do so by using the same push button to pause and resume?  Like a single push button to do both?

marco_c

The meaning you give to the button push depends on your application, so there is no reason that you cannot use the same switch for both. You just need to know if the file is paused or not an then restart or pause (ie, the opposite action).
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

PaulS

The state change detection example shows how to determine that a switch HAS BECOME pressed (or released) and to take different actions based on the number of times that has happened. So, yes, it is possible. Trivial, even.
The art of getting good answers lies in asking good questions.

Go Up