Tutorial.EEPROMWrite History

Hide minor edits - Show changes to output

November 16, 2011, at 04:26 AM by Scott Fitzgerald -
Changed lines 27-28 from:
(:source http://arduino.cc/en/pub/code/master/libraries/EEPROM/examples/eeprom_write/eeprom_write.pde lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino lang=arduino tabwidth=4:)
September 28, 2010, at 01:21 PM by Tom Igoe -
Changed lines 27-60 from:
(:source lang=arduino tabwidth=4:)
#include <EEPROM.h>

// the current address in the EEPROM (i.e. which byte
// we're going to write to next)
int addr = 0;

void setup()
{
}

void loop()
{
// need to divide by 4 because analog inputs range from
// 0 to 1023 and each byte of the EEPROM can only hold a
// value from 0 to 255.
int val = analogRead(A0) / 4;

// write the value to the appropriate byte of the EEPROM.
// these values will remain there when the board is
// turned off.
EEPROM.write(addr, val);

// advance to the next address. there are 512 bytes in
// the EEPROM, so go back to 0 when we hit 512.
addr = addr + 1;
if (addr == 512)
addr = 0;

delay(100);
}
(:sourceend:)

to:
(:source http://arduino.cc/en/pub/code/master/libraries/EEPROM/examples/eeprom_write/eeprom_write.pde lang=arduino tabwidth=4:)
September 23, 2010, at 10:46 PM by Christian Cerrito -
Changed lines 3-4 from:
!!EEPROM Write
to:
!!!EEPROM Write
September 20, 2010, at 02:26 PM by Christian Cerrito -
Added lines 70-71:

September 20, 2010, at 02:26 PM by Christian Cerrito -
Changed lines 63-64 from:
* [[Reference/EEPROMWrite | @@'EEPROM.write()@@ ]]
* [[Reference/Analogread | @@analogRead()@@ ]]
to:
* [[Reference/EEPROMWrite | @@EEPROM.write()@@ ]]
* [[Reference/AnalogRead | @@analogRead()@@ ]]
September 20, 2010, at 02:25 PM by Christian Cerrito -
Added lines 63-66:
* [[Reference/EEPROMWrite | @@'EEPROM.write()@@ ]]
* [[Reference/Analogread | @@analogRead()@@ ]]
* [[Reference/If | @@if()@@ ]]
September 20, 2010, at 02:16 PM by Christian Cerrito -
Changed lines 5-6 from:
Stores values read from analog input 0 into the EEPROM. These values will stay in the EEPROM when the board is turned off and may be retrieved later by another sketch.
to:
The microcontroller on the Arduino board has 512 bytes of [[ http://en.wikipedia.org/wiki/EEPROM | EEPROM:]] memory whose values are kept when the board is turned off (like a tiny hard drive).

This example illustrates how to store values read from analog input 0 into the EEPROM using the[[Reference/EEPROMWrite | '''EEPROM.write()''' ]] function. These values will stay in the EEPROM when the board is turned off and may be retrieved later by another sketch.
September 20, 2010, at 02:13 PM by Christian Cerrito -
Added lines 7-12:
(:div class=BOM :)
!!!Hardware Required
* Arduino Board
(:divend:)

September 20, 2010, at 12:03 AM by Christian Cerrito -
Added lines 7-16:
!!!Circuit
(:div class=circuit :)
There is no circuit for this example.

%height=250px%[[Attach:Arduino_bb.png | Attach:Arduino_bb.png]]
[-image developed using [[http://www.fritzing.org |Fritzing]]. For more circuit examples, see the [[http://fritzing.org/projects/|Fritzing project page]] -]

(:divend:)

September 16, 2010, at 11:11 PM by Tom Igoe -
Changed line 25 from:
int val = analogRead(0) / 4;
to:
int val = analogRead(A0) / 4;
September 16, 2010, at 11:11 PM by Tom Igoe -
Changed line 9 from:
[@
to:
(:source lang=arduino tabwidth=4:)
Changed lines 40-41 from:
@]
to:
(:sourceend:)

May 22, 2008, at 04:33 AM by David A. Mellis -
Changed lines 40-46 from:
@]
to:
@]

!!!See also

* [[EEPROMClear | EEPROM Clear example]]
* [[EEPROMRead | EEPROM Read example]]
* [[Reference/EEPROM | EEPROM library reference]]
May 22, 2008, at 04:30 AM by David A. Mellis -
Added lines 1-40:
''Examples > EEPROM Library''

!!EEPROM Write

Stores values read from analog input 0 into the EEPROM. These values will stay in the EEPROM when the board is turned off and may be retrieved later by another sketch.

!!!Code

[@
#include <EEPROM.h>

// the current address in the EEPROM (i.e. which byte
// we're going to write to next)
int addr = 0;

void setup()
{
}

void loop()
{
// need to divide by 4 because analog inputs range from
// 0 to 1023 and each byte of the EEPROM can only hold a
// value from 0 to 255.
int val = analogRead(0) / 4;

// write the value to the appropriate byte of the EEPROM.
// these values will remain there when the board is
// turned off.
EEPROM.write(addr, val);

// advance to the next address. there are 512 bytes in
// the EEPROM, so go back to 0 when we hit 512.
addr = addr + 1;
if (addr == 512)
addr = 0;

delay(100);
}
@]

Share