Class library for a polling-based 4x4 keypad.
Fork of Keypad2 by
Keypad Class Reference
Class library for a polling-based 4x4 keypad. More...
#include <Keypad.h>
Public Member Functions | |
Keypad (PinName col1, PinName col2, PinName col3, PinName col4, PinName row1, PinName row2, PinName row3, PinName row4) | |
Create a Keypad object. | |
char | ReadKey () |
Returns the letter of the key pressed. |
Detailed Description
Class library for a polling-based 4x4 keypad.
Example:
#include "mbed.h" #include "Keypad.h" char kpdLayout[4][4] = {{'1' ,'2' ,'3' ,'4'}, //row0 {'4' ,'5' ,'6' ,'B'}, //row1 {'7' ,'8' ,'9' ,'C'}, //row2 {'*' ,'0' ,'#' ,'D'}}; //row3 Keypad kpad(PE_15, PE_14, PE_13, PE_12, PE_11, PE_10, PE_9, PE_8); int main() { char key; int released = 1; while(1){ key = kpad.ReadKey(); //read the current key pressed if(key == '\0') released = 1; //set the flag when all keys are released if((key != '\0') && (released == 1)) { //if a key is pressed AND previous key was released printf("%c\n", key); released = 0; //clear the flag to indicate that key is still pressed } } }
Definition at line 64 of file Keypad.h.
Constructor & Destructor Documentation
Keypad | ( | PinName | col1, |
PinName | col2, | ||
PinName | col3, | ||
PinName | col4, | ||
PinName | row1, | ||
PinName | row2, | ||
PinName | row3, | ||
PinName | row4 | ||
) |
Create a Keypad object.
- Parameters:
-
col1..4 DigitalOut (or BusOut) compatible pins for keypad Column data lines row1..4 DigitalIn (or BusIn) compatible pins for keypad Row data lines
Definition at line 21 of file Keypad.cpp.
Member Function Documentation
char ReadKey | ( | ) |
Returns the letter of the key pressed.
- Parameters:
-
None
- Returns:
- The character of the key pressed. Returns '\0' if no key is pressed.
Definition at line 23 of file Keypad.cpp.
Generated on Thu Jul 14 2022 03:48:57 by 1.7.2