Debian Codegraph @

libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino

raw
1 /***
2 eeprom_iteration example.
3
4 A set of example snippets highlighting the
5 simplest methods for traversing the EEPROM.
6
7 Running this sketch is not necessary, this is
8 simply highlighting certain programming methods.
9
10 Written by Christopher Andrews 2015
11 Released under MIT licence.
12 ***/
13
14 #include <EEPROM.h>
15
16 void setup() {
17
18 /***
19 Iterate the EEPROM using a for loop.
20 ***/
21
22 for (int index = 0 ; index < EEPROM.length() ; index++) {
23
24 //Add one to each cell in the EEPROM
25 EEPROM[ index ] += 1;
26 }
27
28 /***
29 Iterate the EEPROM using a while loop.
30 ***/
31
32 int index = 0;
33
34 while (index < EEPROM.length()) {
35
36 //Add one to each cell in the EEPROM
37 EEPROM[ index ] += 1;
38 index++;
39 }
40
41 /***
42 Iterate the EEPROM using a do-while loop.
43 ***/
44
45 int idx = 0; //Used 'idx' to avoid name conflict with 'index' above.
46
47 do {
48
49 //Add one to each cell in the EEPROM
50 EEPROM[ idx ] += 1;
51 idx++;
52 } while (idx < EEPROM.length());
53
54
55 } //End of setup function.
56
57 void loop() {}