| 1 |
/* |
| 2 |
* EEPROM Clear |
| 3 |
* |
| 4 |
* Sets all of the bytes of the EEPROM to 0. |
| 5 |
* Please see eeprom_iteration for a more in depth |
| 6 |
* look at how to traverse the EEPROM. |
| 7 |
* |
| 8 |
* This example code is in the public domain. |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <EEPROM.h> |
| 12 |
|
| 13 |
void setup() { |
| 14 |
// initialize the LED pin as an output. |
| 15 |
pinMode(13, OUTPUT); |
| 16 |
|
| 17 |
/*** |
| 18 |
Iterate through each byte of the EEPROM storage. |
| 19 |
|
| 20 |
Larger AVR processors have larger EEPROM sizes, E.g: |
| 21 |
- Arduino Duemilanove: 512 B EEPROM storage. |
| 22 |
- Arduino Uno: 1 kB EEPROM storage. |
| 23 |
- Arduino Mega: 4 kB EEPROM storage. |
| 24 |
|
| 25 |
Rather than hard-coding the length, you should use the pre-provided length function. |
| 26 |
This will make your code portable to all AVR processors. |
| 27 |
***/ |
| 28 |
|
| 29 |
for (int i = 0 ; i < EEPROM.length() ; i++) { |
| 30 |
EEPROM.write(i, 0); |
| 31 |
} |
| 32 |
|
| 33 |
// turn the LED on when we're done |
| 34 |
digitalWrite(13, HIGH); |
| 35 |
} |
| 36 |
|
| 37 |
void loop() { |
| 38 |
/** Empty loop. **/ |
| 39 |
} |