4x4 Matrix 16 Keypad Keyboard Module [S025]
https://www.youtube.com/watch?v=VQytr1awNRM
*GitHub : https://github.com/rdiot/rdiot-s025.git
* Specs
4x4 Matrix
Keypad Keyboard module 16 Button
Size: Approx.42mmX42mm / 1.65x1.65
* Contents
1) row = (1, 2, 3, 4) PIN
2) column = (5, 6, 7, 8) PIN
- Connect
1 ----- D2
2 ----- D3
3 ----- D4
4 ----- D5
5 ----- D6
6 ----- D7
7 ----- D8
8 ----- D9
- Library : ttp://playground.arduino.cc/uploads/Code/keypad.zip
- Key Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27,20,4); // LCD2004
const byte numRows= 4; //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]=
{
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
byte rowPins[numRows] = {2,3,4,5}; //Rows 0 to 3
byte colPins[numCols]= {6,7,8,9}; //Columns 0 to 3
//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
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("S025:4x4 16 keypad");
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
// Serial.print(keypressed);
lcd.setCursor(0,1);
lcd.print("keypressed=" + (String)keypressed + " ");
switch (keypressed)
{
case '0':
lcd.setCursor(0,2);
lcd.print("if=0, then action");
break;
case 'F':
lcd.setCursor(0,2);
lcd.print("if=F, then action");
break;
default:
lcd.setCursor(0,2);
lcd.print("if=defulat ");
break;
}
}
}
'2) Sensor > Keypad' 카테고리의 다른 글
4x3 Matrix 12 Key Membrane Switch Keypad [S228] (0) | 2016.12.13 |
---|---|
4x5 Matrix Array 20 Keypad [S187] (0) | 2016.09.12 |
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 |