You can then put a
float
into the
union
as follows:
Then you can separate an integer into its two bytes for storage in EEPROM as follows:
Reading the
float
back out again requires you to do the reverse. First you assemble the
two bytes into a single
int
, then you put the
int
into the
union
and pull it out again as a
float
.
Storing a String in EEPROM
Writing and reading character strings into the EEPROM
are pretty straightforward; you
just have to write each character at a time, as in the following example:
To read the string back into a character array, you can do something like this:
Dostları ilə paylaş: