skip navigational linksPJRC
Shopping Cart Checkout Shipping Cost Download Website
Home MP3 Player 8051 Tools All Projects PJRC Store Site Map
You are here: Teensy Teensyduino Libraries Keypad Search PJRC

PJRC Store
Teensy, $16
Teensy Pins, $19
Teensy++, $24
Teensy++ Pins, $27
USB Cable, $4
Teensy
Main Page
Getting Started
How-To Tips
Code Library
Projects
Teensyduino
Reference

Keypad Library

Keypad, written by Mark Stanley and Alexander Brevig, allows you to connect a Keypad with row-column matrix wiring.

Download: Keypad.zip (version 1.8)

Hardware Requirements


The keypad's signals may connect to any digital pins, but avoid using the one with a LED attached.

Example Use

This example can be opened from the menu: File > Examples > Keypad > HelloKeypad

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

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);
  }
}
In this screenshot, each key was pressed once.


Each key pressed once.

More Hardware Pictures


Bottom side wiring, 7 signals between keypad and Teensy

Links

Arduino Playground Page/ has more details to use Keypad.