4×4 Keypad Matrix — Diagram & Wiring (with diodes)

Click keys to toggle. The diagram shows where to place diodes and how to wire rows & columns for a microcontroller scan.

Printable, single-file HTML
Keypad (4 rows × 4 columns)
Column wires
Diode direction (arrow points from col→row)
D
Diode at each switch
Pressed: none

Wiring & Explanation

This layout shows a typical 4×4 keypad matrix. Each button connects one column line to one row line when pressed. To avoid "ghosting" when multiple keys are pressed, place a diode on each key so current can flow only in the scanning direction (from driven column into row input). In the sample diagram the diodes are oriented from column → switch → row.

COL0 → MCU pin: C0 (drive)
COL1 → MCU pin: C1
COL2 → MCU pin: C2
COL3 → MCU pin: C3
ROW0 → MCU pin: R0 (read)
ROW1 → MCU pin: R1
ROW2 → MCU pin: R2
ROW3 → MCU pin: R3
/* Wiring will show here after simulation */
Notes:
  • Use small signal diodes (1N4148 or similar) or Schottky (SS14) for lower drop.
  • Diode orientation: from column (driven) to row (read). So the diode anode connects to column, cathode to switch/row side.
  • Give rows pull-ups or configure MCU input with pull-up; drive columns low one-by-one to scan.

Schematic (visual)

Columns (drive) C0 C1 C2 C3 Rows (read) R0 R1 R2 R3