ESP32-HEXKEYPAD
Aim:
To interface 4x4
HexKeypad with ESP32-Microcontroller module and display the pressed numbers on
the Serial monitor.
Description:
To display the
pressed key on the serial monitor.
Hardware Required:
ESP32-Microcontroller
Development board
Pin Connection:
Pin
Mapping:
Development Board
|
ESP32
|
C1
|
I025
|
C2
|
I026
|
C3
|
I05
|
C4
|
I027
|
R1
|
I04
|
R2
|
I012
|
R3
|
I033
|
R4
|
I032
|
Procedure:
1.
The above pin connection shows how to interface
Hexkeypad with ESP32 board.
2.
Do the connections as shown in the pin diagram and
pin mapping.
3.
Connect the USB cable to the board.
4.
Open Arduino IDE .Select DOIT ESP32 DEVKIT V1in
boards and select COM port.
5.
Now verify the program and Upload it.
6.
After uploading is done open serial monitor to
observe the output.
7.
For a particular switch the same number displays on
our serial monitor.
Program:
/* Include the Keypad header file */
#include<Keypad.h>
/* four rows */
const byte ROWS=4;
/* four columns */ constbyteCOLS=4;
/* define the symbols on the buttons of the keypads */ charhexaKeys[ROWS][COLS]={
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
/* connect to the row pinouts of the keypad */ byterowPins[ROWS]={4,12,33,32};
/* connect to the column pinouts of the keypad */ bytecolPins[COLS]={25,26,5,27};
/* initialize an instance of class NewKeypad */ KeypadcustomKeypad=Keypad(makeKeymap(hexaKeys),rowPins,colPins,ROWS,COLS);
/* counter intialization */ intcounter=0;
void setup(void)
{
Serial.begin(9600);
}
void loop(void)
{
/* Key pressed is stored in customkey */ charcustomKey=customKeypad.getKey(); if(customKey)
{
/* Key pressed is stored in customkey */
Serial.println(customKey);
}
}