CNAP

Membrane Keypad Reference

A 4×4 membrane keypad with 16 keys (09, AD, *, #), scanned via 4 row and 4 column lines.

Pin names

NameDescription
R1–R4Row lines
C1–C4Column lines

Attributes

This component has no configurable attributes.

Usage

Connect each row and column pin to a separate GPIO — no resistors needed. Scan the matrix with the Keypad library, which handles debouncing and key mapping.

#include <Keypad.h>

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

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

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

void loop() {
  char key = keypad.getKey();
  if (key) {
    Serial.print("Key: ");
    Serial.println(key);
  }
}

Examples

DescriptionAttrs
Default 4×4 keypad{}

See also

  • Pushbutton — single-key alternative for simpler input
  • DIP Switch 8 — fixed 8-bit input instead of a scanned matrix