diff options
author | Martino Facchin <facchinm@users.noreply.github.com> | 2015-03-24 09:24:00 +0000 |
---|---|---|
committer | Martino Facchin <facchinm@users.noreply.github.com> | 2015-03-24 09:24:00 +0000 |
commit | f2debfa2555fe26f72832378d3fd7e78fe881e0c (patch) | |
tree | 56df9b9963f902cd9565eb4708cf3ff2dff22588 /libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino | |
parent | 8fcf5c94067a052c2c7ead3c2ebcd1381ed37888 (diff) | |
parent | d8656b8c5249c9d06cd8ed96b2061759ab69b5bf (diff) |
Merge pull request #2812 from facchinm/test_pr2794
EEPROM library V2
Diffstat (limited to 'libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino')
-rw-r--r-- | libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino b/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino index b18ff2c..49eb5fe 100644 --- a/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino +++ b/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino @@ -2,22 +2,34 @@ * EEPROM Clear * * Sets all of the bytes of the EEPROM to 0. + * Please see eeprom_iteration for a more in depth + * look at how to traverse the EEPROM. + * * This example code is in the public domain. - */ #include <EEPROM.h> void setup() { - // write a 0 to all 512 bytes of the EEPROM - for (int i = 0; i < 512; i++) + + /*** + Iterate through each byte of the EEPROM storage. + + Larger AVR processors have larger EEPROM sizes, E.g: + - Arduno Duemilanove: 512b EEPROM storage. + - Arduino Uno: 1kb EEPROM storage. + - Arduino Mega: 4kb EEPROM storage. + + Rather than hard-coding the length, you should use the pre-provided length function. + This will make your code portable to all AVR processors. + ***/ + + for ( int i = 0 ; i < EEPROM.length() ; i++ ) EEPROM.write(i, 0); // turn the LED on when we're done digitalWrite(13, HIGH); } -void loop() -{ -} +void loop(){ /** Empty loop. **/ } |