From 5da9792cd61b5ba9eed9fb80874edb52081d6232 Mon Sep 17 00:00:00 2001 From: Chris--A Date: Tue, 24 Mar 2015 13:58:01 +1000 Subject: Fixed EEPROM examples and added readme --- .../EEPROM/examples/eeprom_update/eeprom_update.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'libraries/EEPROM/examples/eeprom_update') diff --git a/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino b/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino index dbf05ec..831056f 100644 --- a/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino +++ b/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino @@ -14,7 +14,7 @@ #include /** the current address in the EEPROM (i.e. which byte we're going to write to next) **/ -int addr = 0; +int address = 0; void setup(){ /** EMpty setup **/ } @@ -32,13 +32,13 @@ void loop() these values will remain there when the board is turned off. ***/ - EEPROM.update(addr, val); + EEPROM.update(address, val); /*** - The function EEPROM.update(addr, val) is equivalent to the following: + The function EEPROM.update(address, val) is equivalent to the following: - if( EEPROM.read(addr) != val ){ - EEPROM.write(addr, val); + if( EEPROM.read(address) != val ){ + EEPROM.write(address, val); } ***/ @@ -54,15 +54,15 @@ void loop() Rather than hard-coding the length, you should use the pre-provided length function. This will make your code portable to all AVR processors. ***/ - addr = addr + 1; - if(addr == EEPROM.length()) - addr = 0; + address = address + 1; + if(address == EEPROM.length()) + address = 0; /*** As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an EEPROM address is also doable by a bitwise and of the length - 1. - ++addr &= EEPROM.length() - 1; + ++address &= EEPROM.length() - 1; ***/ delay(100); -- cgit v1.2.3-18-g5258