I am designing a process that allows users to change certain variables through an LCD and some push buttons. The values are then stored in EEPROM, and dictate how long things will run when certain actions happen.
I know there is a limit to EEPROM writes, but it appears that there is no limit to the number of times that an EEPROM can be read.
I am wondering if it is better to use EEPROM.read every time, or if it is better to create a global variable and set that off of the EEPROM.read, which would only happen at start-up and after a value is changed.
Here are the two examples:
Example 1:
{...
digitalWrite(pin, HIGH);
delay(EEPROM.read(address));
digitalWrite(pin, LOW);
...}
Example 2:
int delayTime;
void setup() {
delayTime = EEPROM.read(address);
}
void loop() {
...
digitalWrite(pin, HIGH);
delay(delayTime);
digitalWrite(pin, LOW);
...
}
I think example 1 is favorable bc it is simpler and avoids creating an extra variable, but I just wanted to check to see if there were any issues with that.
Cheers!