How to save ULong variable value in EEPROM?
Posted: Tue Dec 18, 2018 10:45 am
Hi, I want to save a Ulong Variable (06 digits) in EEPROM, any example for me.?
I get a code from Arduino forum, writing in the eeprom memory locations is ok, but when i tried to get back data from these locations variable only show the value less then 65000. mean only get back Unint value from eeprom. any help pleas...
long EEPROMReadlong(long address) {
long four = EEPROM.read(address);
long three = EEPROM.read(address + 1);
long two = EEPROM.read(address + 2);
long one = EEPROM.read(address + 3);
return ((four << 0) & 0xFF) + ((three <<
& 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
}
void EEPROMWritelong(int address, long value) {
byte four = (value & 0xFF);
byte three = ((value >>
& 0xFF);
byte two = ((value >> 16) & 0xFF);
byte one = ((value >> 24) & 0xFF);
EEPROM.write(address, four);
EEPROM.write(address + 1, three);
EEPROM.write(address + 2, two);
EEPROM.write(address + 3, one);
}
I get a code from Arduino forum, writing in the eeprom memory locations is ok, but when i tried to get back data from these locations variable only show the value less then 65000. mean only get back Unint value from eeprom. any help pleas...
long EEPROMReadlong(long address) {
long four = EEPROM.read(address);
long three = EEPROM.read(address + 1);
long two = EEPROM.read(address + 2);
long one = EEPROM.read(address + 3);
return ((four << 0) & 0xFF) + ((three <<
}
void EEPROMWritelong(int address, long value) {
byte four = (value & 0xFF);
byte three = ((value >>
byte two = ((value >> 16) & 0xFF);
byte one = ((value >> 24) & 0xFF);
EEPROM.write(address, four);
EEPROM.write(address + 1, three);
EEPROM.write(address + 2, two);
EEPROM.write(address + 3, one);
}