Monday, August 01, 2016

Filled Under: , ,

EEPROM Iterations

EEPROM EEPROM Iterations library
The microcontroller on the Arduino boards have 512 bytes of EEPROM: memory whose values are kept when the board is turned off (like a tiny hard drive).

The purpose of this example is to show how to go through the whole EEPROM memory space with different approaches. The code provided doesn’t run on its own but should be used as a surce of code snippets to be used elsewhere.


Step 1: What You Need?

1 x Arduino Board ( Arduino UNO used in this tutorial) 


Don't have components? Don't worry. Just click the component's name. 


Step 2: Build Your Circuit.


Step 3: Upload The Code.

1. Select the Arduino board type: Select Tools >> Board >> Select your correct Arduino board used.

2. Find the port number by accessing device manager on Windows. See the section Port (COM&LPT) and look for an open port named "Arduino Uno (COMxx)". If you are using a different board, you will find a name accordingly. What matters is the xx in COMxx part. In my case, it's COM3. So my port number is 3.


Select the right port: Tools >> Port >> Select the port number.

3. You can find this code in the example of Arduino IDE.
Select File >> Examples >> EEPROM >> eeprom_read

Click press the "upload" button (see the button with right arrow mark).


/***
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() {}


Download:




Sources:https://www.arduino.cc/en/Tutorial/EEPROMIteration

Unknown

Author & Editor

My Robot Education Sdn. Bhd. (Robotedu.my) was founded in 2015 as the first robotics education centre in Malaysia to provide Arduino-based robotics courses for youths. Our vision is to be able to provide robotics education to every youth in Malaysia.

0 comments:

Post a Comment

 

  • Copyright © Arduino Tutorial ™ is a registered trademark.
    Designed by Templateism. Hosted on Blogger Templates.