Create the file counter.txt
and write 0
to it. Everytime the application is restarted the counter is incremented by one.
The source code can also be found on Github in the examples/filesystem
folder.
Build and run the application.
$ cd examples/filesystem
$ make -s BOARD=arduino_due upload
The output in the terminal emulator:
Incrementing the counter in 'counter.txt'.
Counter incremented to 1.
<manually reset the board>
Incrementing the counter in 'counter.txt'.
Counter incremented to 2.
<manually reset the board>
Incrementing the counter in 'counter.txt'.
Counter incremented to 3.