#include <EEPROM.h> // Импортируем бмблиотеку
#include <LiquidCrystal_I2C.h>
#include <GyverButton.h> // библиотека для обработки кнопки
#define BTN_DOWN 12
#define BTN_UP 1
GButton B_UP(BTN_UP);
GButton B_DOWN(BTN_DOWN);
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
lcd.init();
lcd.backlight();
// заполняем EEPROM случайными числами
// for (int i = 0; i < EEPROM.length(); i++) {
// EEPROM.update(i, random(0, 256));
// }
}
void loop() {
static int adress = 0; // переменная хранит в себе адресс текущей ячейки
byte val;
B_UP.tick();
B_DOWN.tick(); // опрос кнопок
if (B_UP.isClick()) {
adress += 1;
val = EEPROM.read(adress);
lcd.clear();
}
if (B_DOWN.isClick()) {
adress -= 1;
val = EEPROM.read(adress);
lcd.clear();
}
adress = constrain(adress , 0, 100); // ограничиваем диапазон адресов
lcd.setCursor(0, 0);
lcd.print("Adress:");
lcd.print(adress);
lcd.setCursor(0, 1);
lcd.print("value: ");
lcd.print(val);
}