// САРВАРОВ ДЕНИС СЭМС-518 ПРАТИКА ЗАДАНИЕ 6
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {8, 7, 6, 9};
byte colPins[COLS] = {A0, A1, A2, A3};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
lcd.begin(16, 2);
lcd.print("Keypad Ready!");
lcd.setCursor(0, 1);
lcd.print("Press any key");
}
void loop() {
char key = keypad.getKey();
if (key) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Pressed: ");
lcd.print(key);
lcd.setCursor(0, 1);
lcd.print("Code: ");
lcd.print((int)key);
}
}