05 June 2010

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

Above is the screen dump for Task 52.
Note the values:
@address 01 - 35
@address 02 - 42
These values are the DEC equivalents of the Hex numbers $23 & $2A,
so the program's working as it should..
The subsequent values are the 'leftovers' from Task 51..

/*
* Project: Task_52_EEPROM_Write_and_readBack
* Author: Jane-Maree Howard
* Date: Friday 14/05/2010
* Platform: Arduino 18
* Purpose: To demonstrate writing to the EEPROM
& reading back from it
* Operation: Description:
Include: library
Declare: eeprom address, eeprom value
Setup(): Write program resides here; Serial Monitor
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
EEPROM.write(01,0x23 ); // write hex23 to eeprom address 01
EEPROM.write(02,0x2A ); // write hex2A to eeprom address 02
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