0
0
Arduinoprogramming~30 mins

EEPROM read and write in Arduino - Mini Project: Build & Apply

Choose your learning style9 modes available
EEPROM read and write
📖 Scenario: You are working on an Arduino project that needs to save a small number permanently, even when the power is off. This is useful for storing settings or counters that should not reset every time the board restarts.
🎯 Goal: Learn how to write a number to the Arduino's EEPROM memory and then read it back to use in your program.
📋 What You'll Learn
Create a variable to hold the number to save
Create a variable for the EEPROM address
Write the number to EEPROM at the given address
Read the number back from EEPROM
Print the read number to the Serial Monitor
💡 Why This Matters
🌍 Real World
Saving settings or counters that must stay even when the Arduino is turned off, like user preferences or device calibration data.
💼 Career
Understanding EEPROM read/write is important for embedded systems programming and IoT device development where persistent storage is needed.
Progress0 / 4 steps
1
Create the number and EEPROM address variables
Create an int variable called numberToSave and set it to 123. Also create an int variable called eepromAddress and set it to 0.
Arduino
Need a hint?

Use int numberToSave = 123; and int eepromAddress = 0; to create the variables.

2
Include EEPROM library and start Serial communication
Add #include <EEPROM.h> at the top. In setup(), start Serial communication at 9600 baud.
Arduino
Need a hint?

Remember to include the EEPROM library and start Serial in setup().

3
Write the number to EEPROM and read it back
In setup(), write numberToSave to EEPROM at eepromAddress using EEPROM.write(). Then read the value back into an int variable called readNumber using EEPROM.read().
Arduino
Need a hint?

Use EEPROM.write(address, value) to save and EEPROM.read(address) to read.

4
Print the read number to Serial Monitor
Add a Serial.println() statement in setup() to print the readNumber variable.
Arduino
Need a hint?

Use Serial.println(readNumber); to show the saved number.