DIYables Keypad Library
Description
Keypad Library for Arduino - DIYables_Keypad
This library is designed for Arduino, ESP32, ESP8266... to work the keypad. It is created by DIYables to work with DIYables keypad, but also work with other brand keypad. Please consider purchasing keypad 3x4 and keypad 4x4 from DIYables to support our work.
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.
Function References: COMING SOON
- DIYables_Keypad(char *keymap, byte *rowPins, byte *columnPins, byte numRows, byte numCols);
- Char getKey();
- Void setDebounceTime(unsigned long time);
Features
- Works with any hardware platform that supports Arduino API.
- It also works with Arduino Uno R4 WiFi and Minima
Available Examples
- Keypad_3x4
/*
Created by DIYables
This example code is in the public domain
Product page: https://diyables.io/products/keypad-3x4
*/
#include <DIYables_Keypad.h> // DIYables_Keypad library
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 3; //three columns
char keys[ROW_NUM][COLUMN_NUM] = {
{ '1', '2', '3' },
{ '4', '5', '6' },
{ '7', '8', '9' },
{ '*', '0', '#' }
};
byte pin_rows[ROW_NUM] = { 9, 8, 7, 6 }; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = { 5, 4, 3 }; //connect to the column pinouts of the keypad
DIYables_Keypad keypad = DIYables_Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM);
void setup() {
Serial.begin(9600);
delay(1000);
Serial.println("Keypad 3x4 example");
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
}
}
- Keypad_4x4
/*
Created by DIYables
This example code is in the public domain
Product page: https://diyables.io/products/keypad-3x4
*/
#include <DIYables_Keypad.h> // DIYables_Keypad library
const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 3; //three columns
char keys[ROW_NUM][COLUMN_NUM] = {
{ '1', '2', '3' },
{ '4', '5', '6' },
{ '7', '8', '9' },
{ '*', '0', '#' }
};
byte pin_rows[ROW_NUM] = { 9, 8, 7, 6 }; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = { 5, 4, 3 }; //connect to the column pinouts of the keypad
DIYables_Keypad keypad = DIYables_Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM);
void setup() {
Serial.begin(9600);
delay(1000);
Serial.println("Keypad 3x4 example");
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
}
}
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |