A simple 4x4 matrix key pad test program
Revision 2:bac691bab19c, committed 2017-05-13
- Comitter:
- Rhyme
- Date:
- Sat May 13 06:49:03 2017 +0000
- Parent:
- 1:be0aa2900453
- Child:
- 3:1c25a2ed28fe
- Commit message:
- tested for Sengoku 4x4 keypad and Aitendo 4x4 keypads
Changed in this revision
| matrix_key_4x4.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/matrix_key_4x4.cpp Thu May 11 01:29:58 2017 +0000
+++ b/matrix_key_4x4.cpp Sat May 13 06:49:03 2017 +0000
@@ -7,14 +7,14 @@
#include "mbed.h"
#if defined (TARGET_KL25Z)
-#define ROW0 PTC9
-#define ROW1 PTC8
-#define ROW2 PTA5
-#define ROW3 PTA4
-#define COL0 PTA12
-#define COL1 PTD4
-#define COL2 PTA1
-#define COL3 PTA2
+#define COL0 PTC7
+#define COL1 PTC0
+#define COL2 PTC3
+#define COL3 PTC4
+#define ROW0 PTC5
+#define ROW1 PTC6
+#define ROW2 PTC10
+#define ROW3 PTC11
#endif
#define NUM_COL 4
@@ -28,28 +28,39 @@
0, 0, 0, 0
} ;
+#if 0
+/* Sengoku 4x4 keypad */
unsigned char key_char[NUM_KEY] = {
- '1', '4', '7', '*',
- '2', '5', '8', '0',
- '3', '6', '9', '#',
- 'A', 'B', 'C', 'D'
+ '1', '2', '3', 'A',
+ '4', '5', '6', 'B',
+ '7', '8', '9', 'C',
+ '*', '0', '#', 'D'
} ;
-
+#endif /* Sengoku 4x4 keypad */
+#if 1
+/* Aitendo HC-54375 */
+unsigned char key_char[NUM_KEY] = {
+ 'C', 'D', 'E', 'F',
+ '9', '0', 'A', 'B',
+ '5', '6', '7', '8',
+ '1', '2', '3', '4'
+} ;
+#endif /* Aitendo HC-54375 */
DigitalIn *col[NUM_COL] ;
DigitalOut *row[NUM_ROW] ;
void init_hardware(void)
{
- col[3] = new DigitalIn(PTC11, PullUp) ;
- col[2] = new DigitalIn(PTC10, PullUp) ;
- col[1] = new DigitalIn(PTC6, PullUp) ;
- col[0] = new DigitalIn(PTC5, PullUp) ;
+ col[3] = new DigitalIn(COL3, PullUp) ;
+ col[2] = new DigitalIn(COL2, PullUp) ;
+ col[1] = new DigitalIn(COL1, PullUp) ;
+ col[0] = new DigitalIn(COL0, PullUp) ;
- row[3] = new DigitalOut(PTC4, 1) ;
- row[2] = new DigitalOut(PTC3, 1) ;
- row[1] = new DigitalOut(PTC0, 1) ;
- row[0] = new DigitalOut(PTC7, 1) ;
+ row[3] = new DigitalOut(ROW3, 1) ;
+ row[2] = new DigitalOut(ROW2, 1) ;
+ row[1] = new DigitalOut(ROW1, 1) ;
+ row[0] = new DigitalOut(ROW0, 1) ;
}
int scan_key(int key[])