#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int lastButtonState = LOW; // Переменная для хранения последнего состояния кнопки
byte invert[8] = { //(\x04 the inverted)
B10101,
B01010,
B01010,
B10001,
B01110,
B00100,
B01110,
B10001
};
byte bunny[8] = {
B01010,
B10101,
B10101,
B01110,
B10001,
B11011,
B10001,
B01110,
};
const int buttonPin = 2; // Пин, к которому подключена кнопка
void setup() {
lcd.begin(16, 2);
lcd.createChar(1, bunny);
lcd.createChar(2, invert);
lcd.home();
pinMode(buttonPin, INPUT); // Устанавливаем режим входа для пина с кнопкой
}
void loop() {
int buttonState = digitalRead(buttonPin); // Считываем состояние кнопки
if (buttonState != lastButtonState) { // Если состояние кнопки изменилось
if (buttonState == HIGH) { // Если кнопка нажата
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("\x02");
} else { // Если кнопка в покое
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("\x01");
}
lastButtonState = buttonState;
}
}