មេរៀនទី២៤៖ Keypad 4x4 - Tann Thona

Telecommunication and Electronic Engineering

Post

Post Top Ad

Sunday, January 10, 2021

មេរៀនទី២៤៖ Keypad 4x4

Keypad 4x4

 

1. Objective

The objective is talk about, how to use keypad 4x4 on arduino.

2. Requirement

  • Arduino Uno x1
  • Keypad 4x4 
  • 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 (08/12/2020)
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'7','8','9','/'},
{'4','5','6','x'},
{'1','2','3','-'},
{'C','0','=','+'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {10, 9, 8, 7}; //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 on keypad .

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona

No comments:

Post a Comment

Post Top Ad