Using the 4x4 Universal 16 Key Keypad for Arduino

The listings at Amazon and other online vendors show this inexpensive membrane keypad as
 "4x4 Universial 16 Key Switch Keypad Keyboard For Arduino." There was no documentation 
for the product, nor were there any links from Amazon. Here are my notes on how to connect 
and test this keypad.

The arrangement of the keys is

1 2 3 A 
4 5 6 B 
7 8 9 C 
* 0 # D

There is a ribbon with 8 wires running from the bottom of the keypad. With the keypad face up,

 the wires connect in sequence from left to right to Arduino digital pins 2 - 9. Don't use digital 
pins 0 and 1 on the Arduino Uno, since they are used for serial communication.

The Arduino Keypad library is available from the Arduino Playground.



 The following code will allow you to test the keypad. As each key is pressed, the corresponding

 character should appear on a separate line in the Arduino IDE's serial console.


#include <Keypad.h>

const byte ROWS = 4; 
const byte COLS = 4; 
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {2,3,4,5}; //connect to row pinouts 
byte colPins[COLS] = {6,7,8,9}; //connect to column pinouts

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}

void loop(){
  char key = keypad.getKey();

  if (key != NO_KEY){
    Serial.println(key);
  }
}

Comments

Popular posts from this blog

LCD/LED TV FLASH BIOS / EPROM programming with Serial Flash Memory - W25Q32FV

Sony Bravia 55" Double image / Image Flickering ( CKV - Clock Vertical Signal ) LED Panel Repairing

Calculate RPM with Hall effect Sensor