/************************************************************************************************** * * Eeprom Config * * Version: 2.0.0 - Mai 2009 * Author: Etienne Ribeiro / tutorial assistant caad / eribeiro[at]ethz.ch * Supervisor: Christoph Wartmann / chair for caad - ETH Zürich / wartmann[at].arch.ethz.ch * * Desc: Basic library to write Byte, Char, Int, Long and String to EEPROM. * ***************************************************************************************************/ // var int onboardLED = 13; // 13 for Arduino, 48 for Wiring // setup void setup () { // LED (2 * blink) pinMode(onboardLED, OUTPUT); digitalWrite(onboardLED, HIGH); delay(200); digitalWrite(onboardLED, LOW); delay(200); digitalWrite(onboardLED, HIGH); // Serial Serial.begin (9600); Serial.println ("EEPROM Config"); // byte vByteIf = 173; // -1; int vIntIf = 12214; // -1; long vLongIf = 139310; // -1; byte vByte = 173; int vInt = 12214; long vLong = 139310; char vString[] = {"a string"}; // Write if (EEPROM_write1 (41, vByte) == true) Serial.println ("Wrote to EEPROM"); if (EEPROM_write2 (42, vInt)) Serial.println ("Wrote to EEPROM"); if (EEPROM_write4 (44, vLong)) Serial.println ("Wrote to EEPROM"); if (EEPROM_writeX (48, "Hi dear", 7)) Serial.println ("Wrote to EEPROM"); // WriteIf if (EEPROM_write1If (vByteIf != -1, 60, vByte)) Serial.println ("Wrote to EEPROM"); if (EEPROM_write2If (vIntIf != -1, 61, vInt)) Serial.println ("Wrote to EEPROM"); if (EEPROM_write4If (vLongIf != -1, 63, vLong)) Serial.println ("Wrote to EEPROM"); if (EEPROM_writeXIf (vString != "", 67, vString, 8)) Serial.println ("Wrote to EEPROM"); // Read byte var001 = EEPROM_read1 (41); int var002 = EEPROM_read2 (42); long var003 = EEPROM_read4 (44); char buffer01[8]; buffer01[7] = 0; EEPROM_readX (48, buffer01, 7); // byte var004 = EEPROM_read1 (60); int var005 = EEPROM_read2 (61); long var006 = EEPROM_read4 (63); char buffer02[9]; buffer02[8] = 0; EEPROM_readX (67, buffer02, 8); // Print Serial.println (var001, DEC); Serial.println (var002, DEC); Serial.println (var003, DEC); Serial.println (buffer01); // "Hi dear" // Serial.println (var004, DEC); Serial.println (var005, DEC); Serial.println (var006, DEC); Serial.println (buffer02); // "a string" } // loop void loop () { }