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_iteration/eeprom_iteration.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_iteration/eeprom_iteration.ino')
-rw-r--r-- | libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino b/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino new file mode 100644 index 0000000..650c90a --- /dev/null +++ b/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino @@ -0,0 +1,57 @@ +/*** + eeprom_iteration example. + + A set of example snippets highlighting the + simplest methods for traversing the EEPROM. + + Running this sketch is not necessary, this is + simply highlighting certain programming methods. + + Written by Christopher Andrews 2015 + Released under MIT licence. +***/ + +#include <EEPROM.h> + +void setup() { + + /*** + Iterate the EEPROM using a for loop. + ***/ + + for( int index = 0 ; index < EEPROM.length() ; index++ ){ + + //Add one to each cell in the EEPROM + EEPROM[ index ] += 1; + } + + /*** + Iterate the EEPROM using a while loop. + ***/ + + int index = 0; + + while( index < EEPROM.length() ){ + + //Add one to each cell in the EEPROM + EEPROM[ index ] += 1; + index++; + } + + /*** + Iterate the EEPROM using a do-while loop. + ***/ + + int idx = 0; //Used 'idx' to avoid name conflict with 'index' above. + + do{ + + //Add one to each cell in the EEPROM + EEPROM[ idx ] += 1; + idx++; + }while( idx < EEPROM.length() ); + + +} //End of setup function. + +void loop(){}
\ No newline at end of file |