4x5 Matrix Array 20 Keypad [S187]
https://www.youtube.com/watch?v=JNL_hOtghXk
*GitHub : https://github.com/rdiot/rdiot-s187.git
* Specs
Panel Size: 75*85mm.
Length: 18CM.
Insulation Resistance:100M 100V.
Withstand Voltage:250V Rms.(50-60Hz lmin)
Storage Temperature: +15°- +35°.
Storage Humidity:70-90.
* Contents
byte rowPins[numRows] = {10,9,8,7,6};
byte colPins[numCols]= {2,3,4,5};
- Connect
D2 ~ D9
- Key Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27,20,4); // LCD2004
const byte numRows= 5; //number of rows on the keypad
const byte numCols= 4; //number of columns on the keypad
//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols]=
{
{'A','B','#','*'},
{'1','2','3','U'},
{'4','5','6','D'},
{'7','8','9','C'},
{'L','0','R','E'}
};
byte rowPins[numRows] = {10,9,8,7,6};
byte colPins[numCols]= {2,3,4,5};
//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
String numstr = "";
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.print("start LCD2004");
delay(1000);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("S187:4x5 20 Keypad");
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
// Serial.print(keypressed);
lcd.setCursor(0,1);
lcd.print("keypressed=" + (String)keypressed + " ");
switch (keypressed)
{
case '1':
numstr = "1 ";
break;
case '2':
numstr = "2 ";
break;
case '3':
numstr = "3 ";
break;
case '4':
numstr = "4 ";
break;
case '5':
numstr = "5 ";
break;
case '6':
numstr = "6 ";
break;
case '7':
numstr = "7 ";
break;
case '8':
numstr = "9 ";
break;
case '0':
numstr = "0 ";
break;
case 'A':
numstr = "F1 ";
break;
case 'B':
numstr = "F2 ";
break;
case 'C':
numstr = "ESC ";
break;
case 'E':
numstr = "ENTER";
break;
case 'D':
numstr = "DOWN ";
break;
case 'U':
numstr = "UP ";
break;
case 'R':
numstr = "RIGHT ";
break;
case 'L':
numstr = "LEFT ";
break;
case '*':
numstr = "* ";
break;
case '#':
numstr = "# ";
break;
default:
break;
}
if(numstr !="")
{
lcd.setCursor(0,2);
lcd.print("numstr=" + (String)numstr + " ");
}
}
}
'2) Sensor > Keypad' 카테고리의 다른 글
4x3 Matrix 12 Key Membrane Switch Keypad [S228] (0) | 2016.12.13 |
---|---|
TTP229 16 Key Capacitive Touch Keypad (TTP229) [S153] (0) | 2016.09.12 |
4x4 Matrix Keyboard Keypad [S188] (0) | 2016.09.12 |
4x4 Matrix Keyboard 16 Key Membrane Switch Keypad [S087] (0) | 2016.09.12 |
4x4 Matrix 16 Keypad Keyboard Module [S025] (0) | 2016.09.12 |