#include <LiquidCrystal.h>
#include <EEPROM.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); // Set the LCD pins
struct Item {
char id[10];
char name[28];
char code[9];
char school[35];
char stem[11];
char year[5];
};
Item storedItem;
void setup() {
lcd.begin(20, 4); // Initialize the LCD module
lcd.print("Stored Item:");
delay(500);
// Store the items in EEPROM
storeItems();
// Read the stored item from EEPROM
readItem();
// Display the stored item on the LCD
displayItem();
}
void loop() {
lcd.scrollDisplayLeft();
delay(100);
}
void storeItems() {
// Item 1
strcpy(storedItem.id, "102216757");
strcpy(storedItem.name, "Sifat Salehin Ananyo");
strcpy(storedItem.code, "ENG20009");
strcpy(storedItem.school, "Swinburne University of Technology");
strcpy(storedItem.stem, "Semester 1");
strcpy(storedItem.year, "2023");
// Write the stored item to EEPROM
EEPROM.put(0, storedItem);
}
void readItem() {
// Read the stored item from EEPROM
EEPROM.get(0, storedItem);
}
void displayItem() {
// Display the stored item on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ID: ");
lcd.print(storedItem.id);
lcd.setCursor(0, 1);
lcd.print("Name: ");
lcd.print(storedItem.name);
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(storedItem.code);
lcd.setCursor(0, 1);
lcd.print(storedItem.stem);
lcd.setCursor(0, 2);
lcd.print(storedItem.year);
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(storedItem.school);
}