Quantcast
Channel: EngineersGarage - eeprom
Viewing all articles
Browse latest Browse all 20

How to Read and Write the EEPROM of Arduino

$
0
0

This Code is only visible to Registered users. Please Login/Register

 

How To Read And Write The EEPROM Of Arduino

Developed By: 

Ajish Alfred
There are different kinds of memory chips found in microcontroller based system and the most common among them are EEPROM chips. The EEPROM stands for Electrically Erasable Programmable Read Only Memory. It is a kind of Read Only Memory (ROM), but it can be written also by means of electrically programming the data. This memory can retain the data even if the power is cut off from the chip and this feature is made use in the microcontroller systems.A microcontroller might need to store its data like sensor value, or a particular count or image data for a long period of time uses the EEPROM memory. The EEPROM memory is also used to save the data before the system switches itself off so that the same data can be retained next time when the system is turned on.
The EEPROM comes in small sized chips which can be interfaced with microcontrollers in a system. Most of the microcontrollers have built-in EEPROM with reasonable memory size so that for small kind of applications an extra memory chip can be avoided.The Arduino boards uses AVR microcontrollers which has built-in EEPROM. This particular project explains how to access the built-in EEPROM of an Arduino board with the help of a simple code which writes some data into the EEPROM and reads back the same data.
How To Read And Write The EEPROM Of Arduino

The Arduino is an easy prototyping platform in which the hardware is very simple to use and to be connected with any other system. The programing environment is also very easy to start with and has lot of built-in functions for every simple and complex task. 

In this project the Arduino pro-mini board is used which is then programmed with the help of Arduino IDE version 1.0.3 on windows operating system. The image of the Arduino pro-mini board and the Arduino IDE is shown in the following;

Arduino

 

Arduino

Another hardware which can perform the USB to TTL conversion is used to upload the program into the arduino board.

Arduino

It is assumed that the reader has gone through the project how to get started with the arduino and done all the things discussed in it.

The Arduino pro-mini board has ATMEGA328 microcontroller inside it which has an internal EEPROM memory of 1Kb. The Arduino IDE provides a library called <EEPROM.h> which provides functions to access the built-in EEPROM of the Arduino board’s microcontroller. The code written for this project also makes use of few functions from the <EEPROM.h> to read and write the built-in EEPROM. The functions are namely EEPROM.write() and EEPROM.read() and the details of those functions are discussed in the following section.

EEPROM.write()

The function EEPROM.write() is used to write a data byte into a particular address of the EEPROM memory mentioned by the parameters passed to the function. The function has two parameters where the first one should be provided with the address of the EEPROM location into which the data need to be written into and the second parameter should be provided with actual data byte. For example if the data ‘A’ need to be written into the address mentioned by the variable ‘addr’ the following statement can be used.

EEPROM.write(addr, ‘A’);

EEPROM.read()

The function EEPROM.read() is used to read a particular data byte from the internal EEPROM of the Arduino’s microcontroller. The function has a single parameter which is the address from which the data should be read from. The function has a return value which is the actual data byte which it read from the address mentioned by the parameter passed into it. For example if the data byte is to be read from the location mentioned by the variable ‘addr’ the following statement can be used.

EEPROM.read(addr);

THE CODE

The code written for this project can write a value 100 into the memory address 30 of the EEPROM and tries to read the value from the same location. The functions EEPROM.write() and EEPROM.read() from the library <EEPROM.h> are used for EEPROM writing and reading respectively. Both the value written into the location and read from the location is shown in a 16*2 LCD with the help of functions from the library <LiquidCrystal.h>. Few functions from the library <LiquidCrystal.h> including those which are used in this particular project are already discussed in the previous projects on how to interface an LCD, how to display sensor value on LCD, how to connect the LCD with the PC and how to make an LCD scrolling display

The code displays the data which is written into the EEPROM in the first line of the 16*2 LCD and the data which is read back from the same location in the second line of the LCD. Once the display on the second line of the 16*2 LCD is done the code starts blinking an LED connected to the pin number 6 continuously with the help of pinMode(), delay() and digitalWrite() functions explained in the previous projects on how to start with Arduino and how to use digital input and output of arduino.

When the coding is finished one can verify and upload the code to the Arduino board as explained in the project how to get started with the Arduino and can verify with the help of the LCD display whether the value written into a memory location of the EEPROM and the value read from the same location matches or not.

16 x 2 LCD | 16x2 Character LCD Module
LCD

 

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are...

LEDs | Light Emitting Diode
LED
 
Light emitting diodes...
Arduino Pro Mini
Arduino Pro Mini

The Arduino Pro Mini is an ATmega168 based microcontroller board. The board comes with built-in arduino bootloader. It has 14 digital input/output pins (of which 6 can be used as PWM...

Resistor Image
Resistor

Resistor is a passive component used to control current in a circuit. Its resistance is given by the ratio of voltage applied across its terminals to the current passing through it. Thus a particular value of resistor, for fixed voltage, limits the current through it. They are omnipresent in...


 
Pick the right product for your next design project with "Mouser Store". Mouser Electronics brings broadest range of semiconductors and electronic components from over 500 industry leading suppliers. 
 
Mouser specializes in the rapid introduction of new products and technologies for design engineers and buyers that includes semiconductors, interconnects, passives, and electro-mechanical components. Providing the best possible service with the flexibility of not requiring a minimum order and same-day shipping, Mouser has it all.
 
 
 
 
When you need the right part right now, think of Mouser
 
Thank you
Team EG

 


Viewing all articles
Browse latest Browse all 20

Trending Articles