- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to clear the EEPROM with Arduino?
Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.
In this article, we will see how to clear the EEPROM, i.e., set all its bytes to 0. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from − File → Examples → EEPROM.
Example
We will look at the eeprom_clear example. It is very easy. You essentially use the EEPROM.write() function, and iterate over the length of the EEPROM, and write 0 at each address.
We begin with the inclusion of the library.
#include <EEPROM.h>
Within the Setup, you set pin 13 as output, and connect an LED to it. Then you make the LED glow once we are done. This is optional though. The code snippet of interest is the for loop wherein we iterate over each address in the EEPROM, till we reach the end of the EEPROM, and write 0 to each address.
void setup() { // initialize the LED pin as an output. pinMode(13, OUTPUT); for (int i = 0 ; i < EEPROM.length() ; i++) { EEPROM.write(i, 0); } // turn the LED on when we're done digitalWrite(13, HIGH); }
Nothing happens in the loop.
void loop() { /** Empty loop. **/ }
- Related Articles
- How to write data into EEPROM with Arduino?
- How to update existing data in EEPROM with Arduino?
- How to get data of any size from the EEPROM with Arduino?
- How to read data from EEPROM in Arduino?
- How to put data of any size in the EEPROM using Arduino?
- How to clear floats with the "clearfix" hack with CSS?
- How to clear all cookies with JavaScript?
- Clear/Set a specific bit of a number in Arduino
- How to clear the text entered in Selenium with python?
- How to clear HTML form fields with jQuery?
- How to clear an entire Treeview with Tkinter?
- How to Use Light Dependent Resistor (LDR) with Arduino?
- How to clear an input field on focus with CSS?
- How to Clear the Canvas for Redrawing?
- Difference Between EPROM and EEPROM
