0Pricing
Arduino & IoT Academy · Lezione

Salvare un valore in EEPROM

Scriva e legga impostazioni non volatili.

Salvare un valore in EEPROM è una lezione Arduino & IoT Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Arduino & IoT Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Arduino & IoT Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Memory That Forgets

Normal variables live in RAM, which wipes clean the moment power drops. To keep a setting around, you need memory that remembers.

Meet EEPROM

EEPROM is a small block of storage built into the chip that survives power loss. Think of it as a tiny notepad that stays written.

How Much Space

An Arduino Uno gives you about 1024 bytes of EEPROM. It is small, so save settings and counters, not big logs.

Addresses, Not Names

EEPROM is organized by numbered slots called addresses, starting at 0. You choose which address holds each value.

Include the Library

To use it, pull in the built-in EEPROM library at the top of your sketch. No download needed; it ships with the IDE.

#include <EEPROM.h>

Write a Byte

EEPROM.write stores one byte at an address. Here we save the number 42 into slot 0.

EEPROM.write(0, 42);

Read It Back

EEPROM.read fetches the byte you stored. Read slot 0 and you get your value back, even after a reset.

byte value = EEPROM.read(0);

One Byte Holds 0 to 255

A single byte stores values from 0 to 255. To save a larger number, you split it across several addresses.

Save Bigger Values Easily

For ints, floats, or structs, use EEPROM.put and EEPROM.get. They handle the byte splitting for you automatically.

int score = 1500;
EEPROM.put(0, score);

Writes Wear Out

EEPROM survives roughly 100,000 writes per cell. Don't write every loop, or you'll burn it out fast.

Write Only on Change

Use EEPROM.update instead of write. It skips the write when the value is unchanged, sparing the memory.

EEPROM.update(0, 42);

Quick Check

Let's check why we reach for EEPROM at all.

Recap: Persistent Storage

You saw EEPROM as non-volatile memory, wrote and read bytes by address, and learned to limit writes. Your settings can now persist! 💾

Domande Frequenti

La lezione «Salvare un valore in EEPROM» è gratuita?

Sì — il testo completo di «Salvare un valore in EEPROM» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Arduino & IoT Academy, passa a CoddyKit PRO. Il corso Arduino & IoT Academy include 4 lezioni in totale.

Cosa imparerò in «Salvare un valore in EEPROM»?

Scriva e legga impostazioni non volatili. Eserciti Arduino & IoT Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Arduino & IoT Academy?

Non è richiesta alcuna esperienza precedente. Arduino & IoT Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.

Quanto tempo richiede la lezione «Salvare un valore in EEPROM»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Arduino & IoT Academy?

Sì. Ogni lezione Arduino & IoT Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Perché i pulsanti hanno il “rimbalzo”
  2. Eseguire il debounce con millis()
  3. Salvare un valore in EEPROM
  4. Ricordare un contatore dopo il reset
← Torna a Arduino & IoT Academy