If I add the previous code snippet to other values I thougth it would perform with the same tempMillis lines OK.
// +++++ Write values to EEPROM when they change after 3 seconds
if (speedstartValue != speedstartValueold)
{
tempMillis = millis() + 3000;
digitalWrite(led11Pin,HIGH);
}
if (tempMillis != 0 && millis() > tempMillis)
{
EEPROM.write(2,speedstartValue);
speedstartValueold = speedstartValue;
tempMillis = 0;
digitalWrite(led11Pin,LOW);
}
if (speedcurveValue != speedcurveValueold)
{
tempMillis = millis() + 3000;
digitalWrite(led11Pin,HIGH);
}
if (tempMillis != 0 && millis() > tempMillis)
{
EEPROM.write(3,speedcurveValue);
speedcurveValueold = speedcurveValue;
tempMillis = 0;
digitalWrite(led11Pin,LOW);
}
if (brakeNValue != brakeNValueold)
{
tempMillis = millis() + 3000;
digitalWrite(led11Pin,HIGH);
}
if (tempMillis != 0 && millis() > tempMillis)
{
EEPROM.write(4,brakeNValue);
brakeNValueold = brakeNValue;
tempMillis = 0;
digitalWrite(led11Pin,LOW);
}
Although the led is ON the changed values are not saved except for the speedstartValue.
But I have to declare temp(Xnumber up)Millis for each extra value I like to save to memory.
Is this a correct behaviour? If these extra millis() are running 10 in total could the program freeze as a result of the large number of millis()
Free Sram 5389 still.
Any workaround if this is the case?
// +++++ Write values to EEPROM when they change after 3 seconds
if (speedstartValue != speedstartValueold)
{
tempMillis = millis() + 3000;
digitalWrite(led11Pin,HIGH);
}
if (tempMillis != 0 && millis() > tempMillis)
{
EEPROM.write(2,speedstartValue);
speedstartValueold = speedstartValue;
tempMillis = 0;
digitalWrite(led11Pin,LOW);
}
if (speedcurveValue != speedcurveValueold)
{
temp2Millis = millis() + 3000;
digitalWrite(led11Pin,HIGH);
}
if (temp2Millis != 0 && millis() > temp2Millis)
{
EEPROM.write(3,speedcurveValue);
speedcurveValueold = speedcurveValue;
temp2Millis = 0;
digitalWrite(led11Pin,LOW);
}
if (brakeNValue != brakeNValueold)
{
temp3Millis = millis() + 3000;
digitalWrite(led11Pin,HIGH);
}
if (temp3Millis != 0 && millis() > temp3Millis)
{
EEPROM.write(4,brakeNValue);
brakeNValueold = brakeNValue;
temp3Millis = 0;
digitalWrite(led11Pin,LOW);
}
Paco