ESP-32s 用arduino开发的,要连接4*5的按键,以下是按键图
#include <Keypad.h>
const byte ROWS = 5; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'f','F','#','*'},
{'1','2','3','t'},
{'4','5','6','d'},
{'7','8','9','s'},
{'l','0','r','n'}
};
byte rowPins[ROWS] = {34,35,32,33,25}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {26,27,14,13}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();
if (key != NO_KEY){
Serial.println(key);
}
}