#include <ArduinoJson.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Keypad.h>
// for tft screen connection
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define BLUE 0x001F
#define TEAL 0x0438
#define GREEN 0x07E0
#define CYAN 0x07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define ORANGE 0xFC00
#define PINK 0xF81F
#define PURPLE 0x8010
#define GREY 0xC618
#define WHITE 0xFFFF
#define BLACK 0x0000
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys [ROWS] [COLS] = {
{'1' , '2' , '3' , 'A'},
{'4', '5' , '6' , 'B'},
{'7' , '8' , '9' , 'C'},
{'*', '0' , '#' , 'D'}
} ;
byte rowPins [ROWS] = {16, 17, 5, 21};
byte colPins [COLS] = {12, 14, 27, 26};
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(115200);
tft.begin(); // setting the screen
tft.fillScreen(WHITE);
tft.setRotation(0);
}
void loop (){
// Get key value if pressed
char customKey = customKeypad.getKey();
if (customKey) {
// Print key value to serial monitor
Serial.println(customKey);
tft.fillScreen(WHITE);
tft.setCursor(120, 125);
tft.setTextColor(RED);
tft.setTextSize(2);
tft.print(customKey);
}
}