2

I have an arduino code with an SD card where I save some data. When I load a new code, The SD must update with the new data that I put in the code, but if I reset the Arduino by the reset button, I don“t want the SD data to change.

To sum up, I want to reload SD data only when I update the code, and not with hardware reset

Any ideas?

AlexSp3
  • 203
  • 1
  • 8

1 Answers1

3

You can't. There is no "software" reset. When you upload new code a hardware reset is triggered by the DTR pin of the USB interface chip.

Instead I would suggest maintaining a "data version number" on the SD card. Read it on startup and, if it differs from the expected version number (which you update in your code manually) it creates the data for you and sets the version number.

Majenko
  • 105,851
  • 5
  • 82
  • 139