this code not working to store led please help me to correct this

please help to store ledstate
I am a beginner
i want to store delay time also but
i press reset this start from the beginning

#include <EEPROM.h>

int ledPin = 12 ;

void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin (9600);;
void loop() {
digitalWrite(ledPin, HIGH);

digitalWrite(ledPin, LOW);

Did you forget something?

Please remember to use code tags when posting code

In setup();

This reads the value at address 0 and the throws that value away. You would typically store that value in a variable

byte var =;

Also note that EEPROM does not have an infinite life. You can only write to it ~100K times. Your code does this every second so it will add up in a hurry. Why do you need to retain this value in EEPROM?

Time to read :wink:



Also, be careful:

“The EEPROM memory has a specified life of 100,000 write/erase cycles, so you may need to be careful about how often you write to it.”

Why have yo started another thread about storing values to EEPROM ?

Why do you want to store it to EEPROM? You can store it in the program memory with the bool value. You might damage the EEPROM with multiple uses.


This is why you should always state what libraries you are using.
External EEPROM still has limitations. It may do slightly better than the internal EEPROM. Perhaps an order of magnitude (10x].

The exact way to use external eeprom will surely depend on the make and model of that eeprom.

There is (for example) an explanation of i2c eeprom here in the Playground.