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?

asked Jul 5, 2021 at 14:35
4
  • Which Arduino do you have? Commented Jul 5, 2021 at 14:36
  • I´m trying with Arduino Uno, but the code should work for Nano and Mega too Commented Jul 5, 2021 at 14:37
  • Then I'm sorry, you can't. There is no "software reset". Uploading code triggers a hardware reset through "pressing" the reset for you. Commented Jul 5, 2021 at 14:37
  • Ah, so there isn´t real difference between both reset Commented Jul 5, 2021 at 14:39

1 Answer 1

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.

answered Jul 5, 2021 at 14:39
1
  • 1
    Well, I didn´t think about that, sounds like a good solution. Thanks! Commented Jul 5, 2021 at 14:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.