I have programmed a WS 2812 LED for three different colors, by pressing a switch.
first press the blue light glows,
second press the yellow light glows for some time and changes to red.
now when I restart the Arduino mini the sketch starts from the first. where as I would want to remember the last state and then continue the sketch from the previously left state.
for example when I switch off the Arduino mini the state is yellow light then after switching on the sketch should continue from the yellow light and not start from the first Blue light.
If you change address each time you push a button and leave the previously used address at 0XFF then you get into 102,400,000 times before it could potentially go wrong.
Which at one press a second 24 hours a day will give you a life expectancy of 3.29 years.
Grumpy_Mike:
If you change address each time you push a button and leave the previously used address at 0XFF
Mike, isn't the EEPROM organised into pages (64 bytes or something?) and it's the pages that wear out? This might last only 16 X 100,000 rather than 1024 X 100,000 writes. But that is still more than the OP will ever need. Your suggested approach will spread the wear evenly between the pages.
Actually, it is much easier - and cheaper that all that.
Just add a DS1307 Real Time Clock module with a coin cell and use its battery-backed RAM. You can re-write that as often as you like.
Needless to say, you will no doubt find a convenient use for the RTC as well.
isn't the EEPROM organised into pages (64 bytes or something?) and it's the pages that wear out?
No, not the internal EEPROM. Anyway it is always the individual cells that fail, the fail occurs on the erase cycle not the write cycle.
If you are clever you can write individual bits ( zeros only ) into an address location and it only generates an erase cycle when you try and write a bit pattern that has some bits that need to be a one and there is a zero already stored in it at the same bit. An erase cycle writs all ones into a location. Note you can't do this with the standard EEPROM libiary code.
Of corse the eeprom is limited, but just in writing. So you can write it only if the button state change. After, if it appends too much times you can add another botton to press sometimes and if the button added is pressed you, only in this case, write on the eeprom. Of corse to do so you wave to know approssimatly when the power goes off.
More, I don't know if the likit is on all EEPROM or for each point (like, the eeprom has 100 bytes, you can write 2000 times for byte, so you can use it 100*2000=200000 times).
Paul__B:
OK, now just who is going to press your switch 100,000 times?
this is to be connected a rotary system for every rotation there will be one click on the switch and Two entries in to the EPPROM, and the rotation is 20 RPM so 20 x 2 writing in to EEPROM.
sunilj:
this is to be connected a rotary system for every rotation there will be one click on the switch and Two entries in to the EPPROM, and the rotation is 20 RPM so 20 x 2 writing in to EEPROM.
Wow - that is seriously weird! We would love to know why you wish to do this.
In any case, the answer with unlimited writing is what I cited in reply #9.
FRAM, trillion and more write cycles. Fast SPI acces speed, and nonvolatile storage (no battery)
MB85RS1MT is a FRAM (Ferroelectric Random Access Memory) chip in a configuration of 131,072 words × 8 bits, using the ferroelectric process and silicon gate CMOS process technologies for forming the nonvolatile memory cells. MB85RS1MT adopts the Serial Peripheral Interface (SPI). The MB85RS1MT is able to retain data without using a back-up battery, as is needed for SRAM. The memory cells used in the MB85RS1MT can be used for 10^13 read/write operations, which is a significant improvement over the number of read and write operations supported by Flash memory and E2PROM. MB85RS1MT does not take long time to write data like Flash memories or E2PROM, and MB85RS1MT takes no wait time.
10^13 = 10,000,000,000,000 10 Trillion!
Plenty of Surface mount parts available also. DIP getting harder to find.