#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
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] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Wire.begin();
lcd.init();
lcd.backlight();
lcd.print("Enter ASCII:");
}
void loop() {
String inputAscii = "";
while (inputAscii.length() < 3) {
char key = keypad.getKey();
if (key) {
inputAscii += key;
lcd.setCursor(0, 1);
lcd.print("ASCII: ");
lcd.print(inputAscii);
}
}
char ch = asciiToChar(inputAscii);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ASCII: ");
lcd.print(inputAscii);
lcd.setCursor(0, 1);
lcd.print("Char: ");
lcd.print(ch);
delay(2000);
lcd.clear();
lcd.print("Enter ASCII:");
}
char asciiToChar(String asciiValue) {
return char(atoi(asciiValue.c_str()));
}