diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d22fb8e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "eeprom/lib/AT24Cx"] + path = eeprom/lib/AT24Cx + url = https://github.com/cyberp/AT24Cx.git diff --git a/eeprom-search/eeprom-search.ino b/eeprom-search/eeprom-search.ino new file mode 100644 index 0000000..5cef251 --- /dev/null +++ b/eeprom-search/eeprom-search.ino @@ -0,0 +1,41 @@ + +/* +* +* Search for an EEPROM. +* This sketch iterate the eight possible I2C addresses and +* checks if an EEPROM is found. +* +* Written by Christian Paul, 2014-11-24 +* +* +*/ + +// include libraries +#include + +// setup +void setup() { + Serial.begin(9600); + Serial.println("AT24CX search"); + Serial.println("-------------------------"); + + Wire.begin(); + int i2c = 0x50; + for (int i=0; i<8; i++) { + Serial.print("Search at ["); + Serial.print(i2c, HEX); + Serial.print("]: "); + Wire.beginTransmission(i2c); + int result = Wire.endTransmission(); + if (result==0) + Serial.println("FOUND!"); + else + Serial.println("not found"); + i2c++; + } + +} + +// main loop +void loop() {} + diff --git a/eeprom/eeprom.ino b/eeprom/eeprom.ino new file mode 100644 index 0000000..782b8e9 --- /dev/null +++ b/eeprom/eeprom.ino @@ -0,0 +1,29 @@ +#include "lib/AT24Cx/AT24CX.h" +#include "lib/AT24Cx/AT24CX.cpp" + +char dataTemplate[] = "Heya!"; +AT24C64 eeprom; + +void setup() { + Serial.begin(9600); +} + + +void loop() { + Serial.print("Writing to chip - "); + eeprom.writeChars(200, dataTemplate, sizeof(dataTemplate)); + Serial.println("done"); + Serial.print("Data: "); + Serial.print(dataTemplate); + Serial.println(); + delay(1000); + + + Serial.print("Data on chip: '"); + char data[5]; + eeprom.readChars(200, data, sizeof(data)); + Serial.print(data); + Serial.println("'"); + delay(1000); +} + diff --git a/eeprom/lib/AT24Cx b/eeprom/lib/AT24Cx new file mode 160000 index 0000000..a271dcb --- /dev/null +++ b/eeprom/lib/AT24Cx @@ -0,0 +1 @@ +Subproject commit a271dcb7a1a4881692fd81f13f53f80b1863bf24