Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Needed to access the eeprom read write functions
- #include <EEPROM.h>
- int tempoD1 = 928;
- int tempoD2 = 1445;
- int tempoD3 = 7984;
- //---------------------
- void EEPROMWriteInt(int address, int value)
- {
- byte two = (value & 0xFF);
- byte one = ((value >> 8) & 0xFF);
- EEPROM.update(address, two);
- EEPROM.update(address + 1, one);
- }
- //-----------------------
- long EEPROMReadInt(int address)
- {
- int two = EEPROM.read(address);
- int one = EEPROM.read(address + 1);
- return ((two << 0) & 0xFF) + ((one << 8) & 0xFFFF);
- }
- //------------------------
- void setup()
- {
- Serial.begin(9600);
- }
- //-------------------------
- void loop()
- {
- delay(5000);
- int eeAddress = 0;
- EEPROMWriteInt(eeAddress, tempoD1);
- eeAddress += sizeof(int);
- EEPROMWriteInt(eeAddress, tempoD2);
- eeAddress += sizeof(int);
- EEPROMWriteInt(eeAddress, tempoD3);
- eeAddress = 0;
- Serial.print(tempoD1);
- Serial.print(" = ");
- Serial.println(EEPROMReadInt(eeAddress));
- Serial.print(tempoD2);
- Serial.print(" = ");
- Serial.println(EEPROMReadInt(eeAddress += sizeof(int)));
- Serial.print(tempoD3);
- Serial.print(" = ");
- Serial.println(EEPROMReadInt(eeAddress += sizeof(int)));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement