EEPROM (EEPROM Class)

The microcontroller on the GR-ADZUKI board has Data Flash memory that can be used like EEPROM. The values of EEPROM are kept when the board is turned off. This library enables you to read and write those bytes. 8K bytes are available.

If you use this library, #include <EEPROM.h> should be described.

read

Description

Reads a byte from the EEPROM.

Syntax

byte EEPROM.read(int address)

Parameters

address: The location to read from. (0 to 0x1fff)

Returns

The value stored in that location (byte)

write

Description

Writes a byte to the EEPROM.

Syntax

EEPROM.write(int address, byte data)

Parameters

address: The location to write to. (0 to 0x1fff)
data: The value to write. (0 to 255)

Returns

None


Example

The mode is stored and the color of the LED is changed every time the power is turned on.


        #include <Arduino.h>
        #include <EEPROM.h>
         
        #define LED_OFFSET 13
        uint8_t mode;
        void setup() {
          mode = EEPROM.read(0);
          mode++;
          if(mode > 2){
            mode = 0;
          }
          pinMode(mode + LED_OFFSET, OUTPUT);
          pinMode(13, OUTPUT);
          digitalWrite(13, HIGH);
          EEPROM.write(0, mode);
        }
           
        void loop() {
          digitalWrite(mode + LED_OFFSET, LOW);
          delay(100);
          digitalWrite(mode + LED_OFFSET, HIGH);
          delay(100);
         
        }