use EEPROM

hi All,

In my project, i need to write one time on EEPROM, and them always read from EEPROM.

got no code for now, but what i attend to try is... on first time i turn on arduino, he´s read when I get the push button from time to time to write .. this task may repeat for 5 hours.. like:


| || |||| |_________| |...........
on off on on/off off on off......

and when turn on second/third time gome same scheme...

is better to get millis and when arrive to some time/push, make an flag or something like it?

Never used EEPROM, anyone know some exemple like it???

TKS in advance

In my project, i need to write one time on EEPROM

Write what? The state of the switch or the time that the state changed?

this task may repeat for 5 hours.

How many times will the state change? That is the relevant piece of information, not the time that the sketch has run/has to run.

Hi Sir PaulS

tks for reply,

PaulS:

In my project, i need to write one time on EEPROM

Write what? The state of the switch or the time that the state changed?

the time switch had been taken...

PaulS:
this task may repeat for 5 hours.

How many times will the state change? That is the relevant piece of information, not the time that the sketch has run/has to run.

about aprox. 1000/1500, 3000 maximum!!

The general ratio of answers to questions is one to one. Less than that makes it difficult to help you.

Which Arduino are you using?

The UNO has 1K of EEPROM. It you are storing times (unsigned long) in EEPROM, you will be able to store a maximum of 250 times before EEPROM is full. The Mega has 4K, so you'd be able to store 1000 times.

yes is UNO,

Ill be happy with 1000 maximum...

:slight_smile: tks

yes is UNO,

Ill be happy with 1000 maximum...

The maximum on the UNO is 250.

PaulS:

yes is UNO,

Ill be happy with 1000 maximum...

The maximum on the UNO is 250.

Happy agin :stuck_out_tongue:

HI PaulS

Have any tip for me?

TKS

Have any tip for me?

What is the question? You need a sketch that collects the data to be saved in EEPROM. I don’t see that sketch. Saving the data in EEPROM ranges from trivial, using EEPROM_writeAnything(), to somewhat complicated. Keeping track of where to write is the only challenge. Doing so is essential, which will also allow you to determine when the EEPROM is full.

Reading the data is the reverse of writing it (easy using EEPROM_readAnything(); more complicated using other methods). Doing something with the data will be the most challenging part of the whole project.

Well, actually, doing the right thing will be. Doing something useless will be easy. Of course, you’ll do something useless (just printing) a lot in the early stages.