Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <EEPROM.h>
  2.  
  3. void setup() {
  4.   Serial.begin(9600);  
  5.  
  6.   //Zapíše na adresu 10 až 11 číslo 11555
  7.   eepromIntWrite(10, 11555);
  8.  
  9.   // přečte hodnotu z EEPROM z adresy 10 až 11 číslo
  10.   // a odešle ho na serial port
  11.   Serial.println(eepromIntRead(10));
  12. }
  13.  
  14. void loop() {}
  15.  
  16.  
  17. // funkce pro zápis Integeru do EEPROM
  18. void eepromIntWrite(int adresa, int hodnota)
  19. {
  20.  byte byte1 = hodnota;
  21.  byte byte2 = hodnota >> 8;
  22.  EEPROM.write(adresa, byte1);
  23.  EEPROM.write(adresa + 1, byte2);
  24. }
  25.  
  26. // funkce pro čtení Integer z EEPROM
  27. int eepromIntRead(int adr)
  28. {
  29.  int hodnota = EEPROM.read(adr) + ((EEPROM.read(adr+1)) << 8) ;
  30.  return hodnota;
  31. }