// Eeprom sketch 2: Count number of times the button has ever been // pushed (while running this sketch). #define DATA_ADDR 1024 // Any number in 0..eepromSize()-4 (since sizeof(n) is 4) void setup() { /* Nothing to do */ } void loop() { if (buttonDown()) { u32 n; // Scratch storage eepromRead(DATA_ADDR, (u8*) &n, sizeof(n)); // Read current value in EEPROM ++n; // Increment it eepromWrite(DATA_ADDR, (u8*) &n, sizeof(n)); // Write back updated value println(n); // Print new count while (buttonDown()) delay(1); // Wait for button up } }