Part

Keypad, 4x4

Sixteen keys on eight pins. Scan a row at a time, and mind the ghosting.

See every part
  • 8 pins
  • In 4 projects
  • In 2 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Keypad, 4x4 in brief

What it is, and where it sits on the bench.

The 4x4 membrane keypad has sixteen keys, eight pins and no chip inside. Under each key a carbon pad shorts one row trace to one column trace, and that is all it does, which is why a sketch has to scan it: drive one row low, read the four columns with their pull-ups on, and a column that reads low is a key held in that row. Mokxi models the keys as real contacts that pass current both ways, so it keeps the faults of the real part too. Three keys held in a rectangle make the fourth corner read as pressed, the ghosting that membrane keypads without diodes have, and driving a row high while another key shorts it low puts two outputs against each other as it would on a desk. It does not model contact bounce; that lesson belongs to the pushbutton. Click a key in the editor to hold it down.

Family
Inputs
Pins
8

A circuit built around it, running and explained: the Keypad simulator.

Pins

8 pins

Named as the editor names them, so a wire lands where you expect it.

  • R1
  • R2
  • R3
  • R4
  • C1
  • C2
  • C3
  • C4
How to use it

How to use a 4x4 keypad with an Arduino

Eight wires: the four rows and the four columns to eight digital pins. Scan it: set the columns as inputs with pull-ups, drive one row LOW at a time, and read the columns; a column that reads LOW is a key held in that row. Do it every few milliseconds and report a key once, when it first goes down.

Drive rows low, never high, while scanning. With two keys held in one column, a high row would be shorted straight to a low one.

Part pin
Board pin
R1, R2, R3, R4
Pins 9, 8, 7, 6
C1, C2, C3, C4
Pins 5, 4, 3, 2
Arduino Uno: keypad locklive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
How it is modeled

What is true about the Keypad, 4x4, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

A closed key is a real low-resistance contact passing whatever is on either side in either direction. The model does nothing to stop a row driven high while another key shorts it to a driven low, because a real keypad does nothing to stop that either. Ghosting is modeled too: three keys held in a rectangle make the fourth corner read as pressed, because current has a way around through the three that are closed, exactly what a real matrix keypad with no diodes does, and the reason a keypad sketch normally reads one key at a time.

Not modeled

No diodes on the keys. Some keypads add one per key to prevent ghosting, but the cheap membrane kind does not, and neither does this part.

No contact bounce. A real membrane key's carbon pad chatters for a millisecond or two and a scanning sketch has to settle for it; here a key closes exactly once. That is a deliberate omission, not an oversight (the bounce lesson belongs to the pushbutton), but it means a keypad sketch that would need debouncing on the bench runs clean here. There is no contact resistance drift, no row or column capacitance and no settle time after a row is driven, so a scan can be as fast as the firmware likes.

From 4x4 membrane keypad, in full.

Projects

See the Keypad, 4x4 in a project

4 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

2 lessons place it in their own circuits.

Boards

The boards it is shown on

This board has a built-in project with the Keypad, 4x4 in it.

Boards

The Keypad, 4x4 on each board

The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.

Libraries

Arduino libraries for the Keypad, 4x4

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Keypad, 4x4

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.