0
0
Arduinoprogramming~20 mins

EEPROM for storing settings in Arduino - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
EEPROM Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this EEPROM read code?

Consider the following Arduino code that writes and then reads a byte from EEPROM address 10. What will be printed on the Serial Monitor?

Arduino
  #include <EEPROM.h>

  void setup() {
    Serial.begin(9600);
    EEPROM.write(10, 42);
    byte val = EEPROM.read(10);
    Serial.println(val);
  }

  void loop() {}
ACompilation error
B42
C255
D0
Attempts:
2 left
💡 Hint

EEPROM.write stores a byte at the given address, and EEPROM.read retrieves it.

🧠 Conceptual
intermediate
1:00remaining
How many bytes does EEPROM store in a typical Arduino Uno?

What is the size of the EEPROM memory available on a standard Arduino Uno board?

A512 bytes
B2048 bytes
C1024 bytes
D256 bytes
Attempts:
2 left
💡 Hint

Check the Arduino Uno specifications for EEPROM size.

🔧 Debug
advanced
2:00remaining
Why does this EEPROM update code not update the stored value?

The following code is intended to update the EEPROM value at address 5 to 100, but the stored value never changes. What is the problem?

Arduino
  #include <EEPROM.h>

  void setup() {
    Serial.begin(9600);
    byte current = EEPROM.read(5);
    if (current != 100) {
      EEPROM.update(5, 100);
    }
    Serial.println(EEPROM.read(5));
  }

  void loop() {}
AEEPROM.write only works once after reset; subsequent writes are ignored.
BThe code is correct; the value should update to 100.
CEEPROM.write is asynchronous and needs EEPROM.commit() to save changes.
DEEPROM.update does not update if the value is the same, so no change occurs.
Attempts:
2 left
💡 Hint

EEPROM.update only writes if the new value differs from the stored one to reduce wear.

📝 Syntax
advanced
1:30remaining
What error does this EEPROM code produce?

What error will this Arduino code produce when compiled?

Arduino
  #include <EEPROM.h>

  void setup() {
    EEPROM.write(1024, 123);
  }

  void loop() {}
ARuntime error: Address out of range
BNo error, writes 123 at address 1024
CCompilation error: invalid address
DUndefined behavior, may overwrite memory
Attempts:
2 left
💡 Hint

EEPROM size limits valid addresses.

🚀 Application
expert
3:00remaining
How to store and retrieve a struct in EEPROM?

You want to save a struct with multiple settings to EEPROM and read it back. Which code snippet correctly stores and retrieves the struct?

Arduino
  struct Settings {
    int volume;
    bool enabled;
  };

  Settings settings = {10, true};

  void saveSettings() {
    // ???
  }

  void loadSettings() {
    // ???
  }
AUse EEPROM.put(0, settings) to save and EEPROM.get(0, settings) to load.
BUse EEPROM.write(0, settings) to save and EEPROM.read(0) to load.
CConvert struct to string and store with EEPROM.writeString(), then parse on load.
DUse EEPROM.update(0, settings) to save and EEPROM.read(0) to load.
Attempts:
2 left
💡 Hint

EEPROM.put and EEPROM.get handle complex data types like structs.