Electronic Design

Basic Circuit Eliminates Numeric Keypad Polling

Any X-Y switch matrix can be considered with this circuit, which simplifies decoding of the common 4x4 keypad matrix and eliminates having to scan rows or columns.

Rick Mally, Independent Designs LLC

Using eight digital inputs, this circuit simplifies decoding of the common membrane 4x4 keypad matrix and eliminates the traditional requirement of scanning rows or columns. Any X-Y switch matrix, which can be part of some apparatus, can be considered with this device.

The design uses eight pre-biased transistors—four NPN and four PNP. When depressing a given switch, two transistors will turn on via the current through their internal biasing networks, providing a unique signature code that can be recognized and decoded. The generated code, which will be unique for each key, is readable with a simple 8-bit input statement. By enabling a pin-change interrupt on all eight inputs, the keyboard decode program can be entirely interrupt-driven.

Download this article in .PDF format
This file type includes high resolution graphics and schematics when applicable.

The eight lines could also be connected to a shift register, thereby only requiring two to three digital I/O lines for the microprocessor to shift out and read the result.

1. To simplify decoding of a 4x4 keypad matrix, an 8-bit port was configured as inputs using internal pull-up and pull-down resistors the microprocessor.

In the simplest setup, an 8-bit port is configured as inputs, with internal pull-up resistors on bits 0-3 and internal pull-down resistors on bits 4-7 (Fig. 1). This is possible with several microprocessors, including STMicroelectronics’ STM32F100. In fact, this circuit was prototyped with the STM32F100, and wound up delivering excellent results.

The design in Figure 2 employs external pull-up and pull-down resistors. The best solution implements two resistor arrays, such as the widely available four-element surface-mount types—they’re compact, inexpensive, and add only two components to the circuit board. For most pull-up and pull-down applications, 10 kΩ will suffice.

2. This alternate to Figure 1 uses external pull-up and pull-down resistor arrays.

Of course, several combinations are possible when simultaneously pressing two keys, also leading to the generation of unique codes. This scenario works as well—any combination in which the two keys don’t share a common row or column can be decoded.

Rick Mally, sole proprietor of Independent Designs, a small-scale custom electronic design and prototyping firm for clients with a limited budget was home-schooled and self-educated in the electronics field.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.