I'm currently working on a project which is the wireless energy meter. Right now, i've to add a pushbutton to clear memory - writing "0" to the bytes in eeprom, clear the lcd and set values back to zero before it starts counting the energy consumption again, but it should not reset the whole arduino programming. I'm aware of the sketch for eeprom.clear but now, i've to combine program for the pushbutton and eeprom.clear and i've no idea how to start it. I'm using digital pin 8 for the button. Here's my programming i've done so far for the wireless energy meter. Please help, thank you.
I don't really see the problem. In the loop() function read the pin that the button is attached to and if the button is pressed use a for loop to fill the EEPROM with zeroes. Am I missing something ?
Or just use 1 location to indicate if the others have valid data, or not.
If no valid data, sketch doesn't access them (i.e. it is cleared).
If it is valid data, allow reading.
Peter, you are of course right and that is what I meant but did not express clearly. Combining that with CrossRoads suggestion of using one location as a clear/not clear flag would further reduce the chance of writing to the EEPROM when not necessary.