PDA

View Full Version : Storing user input - whassall that about then?



HankMcSpank
- 15th July 2010, 14:17
So I have a very simple program, with a 'variable' preset by me, but my simple program allows a user to override the content of the variable (by turning a potentiometer & pushing a switch to confirm)....ok, all is good - I know how to do that.

But then the PIC is powered off ....alas, when it's next powered up again, the variable is going to be populated with my default value again - that's gonna get tiring very quickly if everytime the pic is powered up, the user has to enter his preferred value each time.

So how can I implement a solution so that *if* the end user changes the variable (from default), then this updated variable is saved (to be read when the PIC is next powered up)

Now I know it's going to involve writing something to non volatile memory - how do I do that & more importantly, how can I instruct my PIC to go & get the value?!

mackrackit
- 15th July 2010, 14:49
To start go here and look at the eeword example
http://melabs.com/resources/samples-pbp-general.htm

Then when the user changes the VAR it is written to the EEPROM.
At the beginning of the code, at startup, the EEPROM location will be read and the value moved to the VAR in question.

HankMcSpank
- 16th July 2010, 22:39
To start go here and look at the eeword example
http://melabs.com/resources/samples-pbp-general.htm

Then when the user changes the VAR it is written to the EEPROM.
At the beginning of the code, at startup, the EEPROM location will be read and the value moved to the VAR in question.

Many thanks for the link - I've looked at it a couple of times & then had to lie down.

I'll give it a few more peaks over the weekend (I'll likely stand on my chair trying to catch the info going above my head!)

Darrel Taylor
- 16th July 2010, 23:15
You may find this useful too.

EEPROM Variables (EE_Vars.pbp)
http://www.picbasic.co.uk/forum/showthread.php?t=2444

The "Linked Variables" does exactly what you're looking for. Post #4.

hth,

HankMcSpank
- 19th July 2010, 15:08
You may find this useful too.

EEPROM Variables (EE_Vars.pbp)
http://www.picbasic.co.uk/forum/showthread.php?t=2444

The "Linked Variables" does exactly what you're looking for. Post #4.

hth,

Many thanks Darrel, that looks it'll fit the bill perfectly.