updateEEPROM16()
[EEPROM]
void updateEEPROM16(unsigned short address, unsigned short value);Description
Updates the EEPROM memory with the specified short value at the specified address.
Parameters
address: the address where the data will be written.
value: the data to be written if the data is different
from the data already stored in the EEPROM memory.
Returns
Nothing.
Example Code
The code initializes the EEPROM with a size of 1024 and a width of 2 bytes and updates the value in the EEPROM memory at the address 0x00 with a counter value, incrementing it by one each time the loop is executed.
void setup() {
beginEEPROM(1024, 2); // initializes the EEPROM memory with a size of 1024 * 2 bytes
writeEEPROM16(0x00, 0x0000); // writes the value 0x0000 to the EEPROM memory at the address 0x00
}
void loop() {
unsigned short value = readEEPROM16(0x00); // reads the value from the EEPROM memory at the address 0x00
value++; // increments the value by one
updateEEPROM16(0x00, value); // updates the value in the EEPROM memory at the address 0x00
}Notes and Warnings
- The
updateEEPROM16()function can only be used after thebeginEEPROM()function. - The
valueparameter must be a 16-bit value (0-65535) or anunsigned short. - If the programmer initializes the EEPROM with a width lower than 2 bytes, the function will write only 8 bits of the data.
