Hello
Stupid question I am sure.
I have a timer value of between 0 and 300 minutes.
This is triggered using a millis() timer (timertrigMillis).
So I set up these variables:
unsigned long timertrigMillis;
byte timerlowByte;
byte timerhighByte;
int timerlength = 300; // Timer length in seconds (This variable can change)
I store the 300 variable in EEPROM with:
timerlowByte = ((timerlength >> 0) & 0xFF); timerhighByte = ((timerlength >> 8) & 0xFF); EEPROM.write(7, timerlowByte); EEPROM.write(8, timerhighByte);
I retrieve them with
timerlowByte = EEPROM.read(7);
timerhighByte = EEPROM.read(8);
timerlength = ((timerlowByte << 0) & 0xFF) + ((timerhighByte << 8) & 0xFF00);
During the code, this timerlength variable can change from the default 300 and is therefore re-saved in EEPROM accordingly.
All this works fine.
But, I then need to convert that stored timerlength variable into the unsigned long timertrigMillis, so that I can use it with my millis() timer routine.
But this doesn't work and I assume it's something to with the conversion between an int and a long.
timertrigMillis = (timerlength * 1000);
Can someone advise?