hello all I need to store on eeprom a decimal value like 2500.I understand I cant put all this value on a single address since the maximum value is 255.My question is how can I splitt this value to then put in on each eeprom byte address ?
You can take two values in the range 0 to 255 to make one value in the range 0 to 65535:
unsigned char hvalue, lvalue; // 8-bit values unsigned int full; // 16-bit value full = hvalue * 256 + lvalue;
your code works but I want the oposite.I need to find the hvalue and the lvalue from the final number.I just have the final number and so I need to find which is the hvalue and the lvalue.Did you have some tip? Thanks for your help
hvalue = full >> 8 lvalue = full & 0xFF
There are even helper functions in the Arduino library:
unsigned char hvalue, lvalue; // 8-bit values unsigned int full; // 16-bit value full = word(hvalue, lvalue); hvalue = highByte(full); lvalue = lowByte(full);