EEPROM parameters when to init.?

Working on a project and I'd like to (On the first boot up) set some defaults in my EEPROM. Then during the lifetime of machine be able to have the user update these values now and then.

But..

How do I know this is the first time the machine has been fired up? Because the first time I'll load defaults But, from then on it'll be (hopefully) loading my parameters from EEPROM.

How does decide?

-jim lee

i don't know if i clearly understood your question, but, EEPROM.read(x) returns 255 by default (ie: not previously written )

Have an address in EEPROM that is the flag for whether the settings have been written in EEPROM. If that EEPROM address contains the special value, then you know to load the settings from EEPROM, otherwise load the defaults.

I do the same thing with an SD card on different projects. You look for the parameter file. If its there, you use it. If not? You create one using defaults.

I don't know how to know if the parameter has been written since compiling.


When I reload a new version of my code, does it reset the eeprom?

-jim lee

Wait wait wait...

Can I set the defaults somehow in the code? Then I can always just read them when the program runs.

-jim lee

jimLee:
Wait wait wait...

Can I set the defaults somehow in the code? Then I can always just read them when the program runs.

-jim lee

Yes. When faced with that sort of problem I just write a small sketch that writes the values need in the setup function. Once this is run I then go on to develop my application without ever having to bother if the EEPROM is initialised because it always is.

I like it! Thanks guys!

-jim lee