-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEEPROM_I2.ino
37 lines (28 loc) · 1.17 KB
/
EEPROM_I2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "I2C_EEPROM.h"
#define EEPROM_ADDR 0x50
void setup() {
Serial.begin(9600);
I2C_EEPROM.begin();
char test[] = "Doing a test of eeprom :)";
char test2[_BUFFER_LENGTH];
unsigned long int a = 7536984;
I2C_EEPROM.write(EEPROM_ADDR, 90, 10);
I2C_EEPROM.put(EEPROM_ADDR, 64, a);
Serial.println("Before test: " + String(test));
Serial.println("Before test2: " + String(test2));
I2C_EEPROM.putString(EEPROM_ADDR, 100, (byte *) test, sizeof(test));
Serial.println("Middle test: " + String(test));
Serial.println("Middle test2: " + String(test2));
Serial.println("Written...");
delay(200);
Serial.println("Reading EEPROM...");
I2C_EEPROM.getString(EEPROM_ADDR, 100, (byte *) test2, sizeof(test));
Serial.println("After test: " + String(test));
Serial.println("After test2: " + String((char *) test2));
a = 100; // Change the value of a before gets from EEPROM
Serial.println("EEPROM at addr 90: " + String(I2C_EEPROM.read(EEPROM_ADDR, 90)));
Serial.println("A before eeprom: " + String(a));
Serial.println("Value returned from get: " + String(I2C_EEPROM.get(EEPROM_ADDR, 64, a)));
Serial.println("A after eeprom: " + String(a));
}
void loop() { }