Monday, August 01, 2016

Filled Under: , ,

EEPROM Clear

EEPROM EEPROM Clear library

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

This example illustrates how to set of all of those bytes to 0, initializing them to hold new information, using the EEPROM.write() function.




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_clear

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

/*
* 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() {
// initialize the LED pin as an output.
pinMode(13, OUTPUT);

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



Download:





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

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.

2 comments:

  1. Thanks... just what I needed

    ReplyDelete
  2. Amazing to read your article and i found it really informative. keep sharing your knowledge for knowledge seekers.
    Arduino Training in Lahore

    ReplyDelete

 

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