/**********************************************************************
Filename : Get Input Characters
Description : Call the Keypad function to set the matrix keyboard and get the value for the matrix keyboard
Auther : www.freenove.com
Modification: 2022/10/25
**********************************************************************/
#include <Keypad.h>
// define the symbols on the buttons of the keypad
char keys[4][4] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[4] = {14, 13, 12, 11}; // connect to the row pinouts of the keypad
byte colPins[4] = {10, 9, 8, 18}; // connect to the column pinouts of the keypad
// initialize an instance of class NewKeypad
Keypad myKeypad = Keypad(makeKeymap(keys), rowPins, colPins, 4, 4);
void setup() {
Serial.begin(115200); // Initialize the serial port and set the baud rate to 115200
Serial.println("ESP32S3 is ready!"); // Print the string "UNO is ready!"
}
void loop() {
// Get the character input
char keyPressed = myKeypad.getKey();
// If there is a character input, sent it to the serial port
if (keyPressed) {
Serial.println(keyPressed);
}
}
コメント