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.
Fig. 2: Typical Arduino Pro-Mini Board
Fig. 3: Arduino IDE Software Window
Another hardware which can perform the USB to TTL conversion is used to upload the program into the arduino board.
Fig. 4: External USB to TTL converter board for programming Arduino and serial communication
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.
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.
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.
Project Source Code
### /*================================= EG LABS ======================================= Display the value written to a particular address in EEPROM and read back the value again and display it again in the 16*2 LCD once displayed the values the LED starts blinking The circuit: * LED attached from pin 6 to ground through a 1K resistor * Potentiometer attached to analog input A0 * one side pin (either one) to ground * the other side pin to +5V LCD: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 5 * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD pin 3 * LED anode attached to digital output 6 * LED cathode attached to ground through a 1K resistor //================================= EG LABS =======================================*/ #include <EEPROM.h> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the LCD library with the numbers of the interface pins int address = 30; // the variable which holds the address in the eeprom int write_value = 100; // the variable which holds the data need to be written to the eeprom int read_value = 0; // the variable which holds the data which is read from the eeprom int led = 6; // variable which holds the pin number at which the LED is connected void setup() { pinMode(led, OUTPUT); // initialize the led pin as an output. lcd.begin(16, 2); // set up the LCD's number of columns and rows: lcd.print("ENGINEERS GARAGE"); delay(2000); lcd.clear(); EEPROM.write(address, write_value); // write the value to the EEPROM address lcd.print("written : "); // display the value written in first line lcd.print(write_value); delay(2000); read_value = EEPROM.read(address); // read the value from the address lcd.setCursor(0, 1); // display the value read from the EEPROM in the second line lcd.print("read : "); lcd.print(read_value); } void loop() { //---- blink LED -----// digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); delay(1000); //---- blink LED -----// } ###
Circuit Diagrams
Project Components
Project Video
Filed Under: Arduino Projects
Filed Under: Arduino Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.