Keypad Access 4x4 With Arduino

1,555

23

About: Electronics Component - PCB [Design, Printing, Inserting] - Electronic Programming

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

    • Indoor Lighting Contest

      Indoor Lighting Contest
    • Make It Fly Challenge

      Make It Fly Challenge
    • Growing Beyond Earth Maker Contest

      Growing Beyond Earth Maker Contest

    Discussions