Basic Library
Digital I/O
Analog I/O
Advanced I/O
Time
Math
Trigonometry
Random Numbers
Bits and Bytes
Interrupts
Serial Comm.
Standard Library
Servo Motor
Stepping Motor
Character LCD
EEPROM
SPI
I2C (Wire)
SD Card
SD (File Operations)
Ethernet
Ethernet (Server)
Ethernet (Client)
Firmata
Periodic Operation
Power Save
Clock (RTC)
SoftwareSerial
Utility
EEPROM (EEPROM Class)
The microcontroller on the GR-COTTON 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, #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 22
uint8_t mode;
void setup() {
mode = EEPROM.read(0);
mode++;
if(mode > 2){
mode = 0;
}
pinMode(mode + LED_OFFSET, OUTPUT);
EEPROM.write(0, mode);
}
void loop() {
digitalWrite(mode + LED_OFFSET, LOW);
delay(100);
digitalWrite(mode + LED_OFFSET, HIGH);
delay(100);
}