eeprom2.cpp
This sketch uses four bytes of EEPROM to remember how many times the button has been pushed, even across power failures and reboots. It illustrates a way to do writing and reading of multibyte values to and from the EEPROM.
#define DATA_ADDR 1024 // Any number in 0..eepromSize()-4 (since sizeof(n) is 4)
void setup() { }
void loop() {
if (buttonDown()) {
u32 n;
eepromRead(DATA_ADDR, (u8*) &n, sizeof(n));
++n;
eepromWrite(DATA_ADDR, (u8*) &n, sizeof(n));
println(n);
while (buttonDown()) delay(1);
}
}