PIC microcontroller's 4 & 215; 4 determinant keyboard works

Single chip microcomputer STM32L151CCU6

How a 4×4 matrix keyboard works with a PIC microcontroller:

(1) The principle of the single-chip microcontroller's keyboard system

Compared to an independent keyboard, a matrix keyboard has a more complex wiring structure and requires more complicated programming. However, it allows for more keys to be connected using the same number of I/O ports. The schematic diagram is shown in Figure 1.

Figure 1: Schematic of a 4×4 matrix keyboard

In practical applications, devices like the PIC16C5X can be used as a programmable interface for both keyboard input and display control. This single-chip device supports matrix keyboards with up to 64 keys, offering continuous scanning, automatic debouncing, key recognition, and protection against multiple key presses simultaneously.

In the display section, it provides a scan-enabled interface for LED or fluorescent displays, supporting up to 16 characters or numbers through multiplexed signals.

To detect a key press, the column lines are set to low, and the row lines are read. If any row line is pulled low, it indicates that a key is pressed. The exact key can be determined by sequentially setting each column to low and checking the row states.

(2) Single-chip keyboard scanning method

The scanning method involves checking each row or column in sequence after confirming a key press. If a row or column is not all high, the key is located at the intersection of the low row and column. This process is repeated for accurate detection.

The scanning method typically uses pull-up resistors on the rows or columns, ensuring that only one line is active at a time. In Figure 1, the rows and columns are connected to +5V, and the columns are scanned one by one.

1. Progressive (or column) scan query method

This is one of the most commonly used methods for identifying a key press. The process includes:

  • Determine if any key is pressed by setting all row lines low and checking the column lines. If any column is low, a key is pressed.
  • Once a key is detected, the rows are set low one by one. When a row is low, check the column lines. The column that is low corresponds to the pressed key.

2. Inversion method

This method reduces the number of scans needed to identify a key. It works in two steps, as shown in Figure 2.

Figure 2: Principle of line inversion

The hardware operates in interrupt mode, using an 8-bit I/O port to form a 4×4 keyboard. Suppose the key in the diagram is pressed. The inversion method proceeds as follows:

  1. Set D3-D0 as column inputs and D7-D4 as row outputs. Set D7-D4 to 0000. If a key is pressed, the AND gate output goes low, triggering an interrupt to the CPU.
  2. Reverse the direction: D7-D4 become inputs, and D3-D0 become outputs. Read the data from the I/O port and store it in memory. The row position is identified by the low bit in D7-D4.
  3. Combine the column and row positions from the two memory units to determine the key value.

Conclusion: In MCU systems, any I/O port or extended I/O port can be used to create a matrix keyboard. Since such systems often include a display, it's common to integrate the display and keyboard into a single interface circuit to save I/O resources. This approach improves efficiency and simplifies design.

Lamp Pole

Yixing Futao Metal Structural Unit Co. Ltd. is com manded of Jiangsu Futao Group.
It is located in the beach of scenic and rich Taihu Yixing with good transport service.
The company is well equipped with advanced manufacturing facilities.
We own a large-sized numerical control hydraulic pressure folding machine with once folding length 16,000mm and the thickness 2-25mm.
We also equipped with a series of numerical control conveyor systems of flattening, cutting, folding and auto-welding, we could manufacture all kinds of steel poles and steel towers.
Our main products: high & medium mast lighting, road lighting, power poles, sight lamps, courtyard lamps, lawn lamps, traffic signal poles, monitor poles, microwave communication poles, etc. Our manufacturing process has been ISO9001 certified and we were honored with the title of the AAA grade certificate of goodwill"
Presently 95% of our products are far exported to Europe, America, Middle East, and Southeast Asia, and have enjoyed great reputation from our customers,
So we know the demand of different countries and different customers.
We are greatly honored to invite you to visit our factory and cheerfully look forward to cooperating with you.

Lighting Pole,Steel Lamp Pole,Street Light Poles,Garden Lamp Post

JIANGSU XINJINLEI STEEL INDUSTRY CO.,LTD , https://www.chinasteelpole.com