Keypad Access 4x4 With Arduino

766

23

Posted

Introduction: Keypad Access 4x4 With Arduino

The 4x4 keypad is a composite of 16 keys arranged like a matrix. The method used for accessing 4x4 keypad with matrix scanning method. The 4x4 keypad requires 8 pins to access it, ie 4 pins for the columns and 4 pins for the line. How the scanning method works is that the column pin takes the LOW logic interchangeably, then the line pin performs the readings in turn as well.

Step 1: Materials You Need

You will need:

  • Arduino
  • Keypad 4x4
  • Jumper Wires

Step 2: Pin Out

  1. PIN A3 --> pin to 0 row
  2. PIN A2 --> pin to 1 row
  3. PIN A1 --> pin to 2 row
  4. PIN A0 --> pin to 3 row
  5. PIN 4 --> pin to 0 colomn
  6. PIN 5 --> pin to 1 colomn
  7. PIN 6 --> pin to 2 colomn
  8. PIN 7 --> pin to 3 colomn

Step 3: Schematic

Connect each component as the picture above.

Step 4: Code

#include <Keypad.h> //import library keypad
const byte ROWS = 4; //number of colomn
const byte COLS = 4; //number of row
char hexaKeys[ROWS][COLS] = {
 {'1','2','3','A'},
 {'4','5','6','B'},
 {'7','8','9','C'},
 {'*','0','#','D'}
};
byte rowPins[ROWS] = {A3, A2, A1, A0}; //pin used for row
byte colPins[COLS] = {4, 5, 6, 7}; //pin used for colomn
//initialization variable
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);
 }
}

Step 5: Output

Check the output!

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Paper Contest 2018

    Paper Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

Comments