Keypad 4x6
1. Objective
The objective is talk about, how to use keypad 4x6 on arduino.
2. Requirement
- Arduino Uno x1
- Keypad 4x6
- USB Cable x1 (No need in simulation)
- Breadboard x1 (No need in simulation)
- Electronic Wire (No need in simulation)
3. Build Circuit
Build circuit like Figure 1.
Figure 1. Arduino Connection |
4. Coding
Make sure you are ready add keypad library on arduino IDE before write keypad matrix code. if you are not yet add keypad library, so follow instruction install library show below:
Step 1: Your computer have to connect internet.
Step 2: On arduino IDE, Sketch → Include Library → Manage Libraries
Step 3: After show form like figure 2, so search "keypad" and install it.
Figure 2. Keypad Installation |
After install keypad library now you can program on arduino.
// Coding by Tann Thona
(10/12/2020
)
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 6; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'C','7','8','9','X','/'},
{'A','4','5','6','-','R'},
{'%','1','2','3','+','D'},
{'R','0','.','=','+','P'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {11, 10, 9, 8, 7, 6}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey){
Serial.println(customKey);
}
}
Click Here to Download Code and Proteus Simulation File
4. Result
According to code above, when we click on keypad then on virtue terminal or serial monitor will display character as symbol in matrix code.Watch Video Explain in Khmer
YouTube: ICT4D-KH
Copyright By Tann Thona
No comments:
Post a Comment