05 June 2010

Task 53 - Read/Write EEPROM program: software & screeen dump: software


As can be seen, the value 171 has been loaded into all addresses from 0 to 511.
DEC 171 = $AB (10x16+11)


/*
* Project: /*
* Project: Task_53_EEPROM_Write_and_readBack
* Author: Jane-Maree Howard
* Date: Saturday 05/06/2010
* Platform: Arduino 18
* Purpose: To demonstrate writing to the EEPROM
using a for-loop, reading back from it
& printing to the Serial Monitor(SM).
* Operation: Description:
Include: library
Declare: eeprom address, eeprom value
Setup(): Write program resides here; initialise SM
Loop(): Read & SM output program resides here
*/

#include EEPROM.h // needed for using EEPROM

int a = 0; // eeprom address
int value; // value stored at eeprom address

void setup()
{
Serial.begin(9600); // Serial Monitor
for (a=0; a<512; a++)
{
EEPROM.write(a,0xAB ); // write hexAB to eeprom address 'a'
}//for(a..)
a = 0; // reading start address
}//end setup()

void loop()
{
value = EEPROM.read(a); // starting from address a=0..

Serial.print(a); //..read & print to SM the address..
Serial.print("\t");
Serial.print(value); //..& the value stored there
Serial.println();

a = a + 1; // next address (increment)

if (a == 512) //..start all over again
a = 0;

delay(500);
}//end loop()

VERY IMPORTANT!!
In the above codings there are
#include EEPROM.h
statements.
Around the EEPROM.h there should be 'less-than' &
'greater-than' symbols.
these don't show up in these blog postings..
..don't forget them!
*/

No comments:

Post a Comment