Matrix keyboard principle and structure

The keyboard structure of the matrix structure is more complicated. The column line is connected to the positive power supply through the resistor, and the I/O port of the MCU connected to the line line is used as the output end, and the I/O port connected to the column line is used as the input. Thus, when the button is not pressed, all inputs are high, indicating no key press. The line output is low. Once the button is pressed, the input line is pulled low. Thus, by reading the status of the input line, it is known whether a key has been pressed.

In a matrix keyboard , each horizontal line and vertical line are not directly connected at the intersection, but are connected by a button. In this way, a port (such as the P1 port) can constitute 4*4=16 buttons, which is twice as large as the port line is directly used for the keyboard, and the more the number of lines, the more obvious the difference, for example, adding another line. It can form a 20-key keyboard, and the port line can only use one more button (9-key). It can be seen that when the number of keys required is relatively large, it is reasonable to use the matrix method to make the keyboard.

<1> Determining which key on the matrix keyboard is pressed introduces a "line scan method".

The line scan method is also called the line-by-row (or column) scan query method. It is the most commonly used method for key recognition. The keyboard shown in the above figure is introduced as follows.

1. Determine whether there is a key in the keyboard. Press all the line lines Y0-Y3 to low level, and then check the status of the column lines. As long as the level of one column is low, it means that there are keys pressed in the keyboard, and the closed keys are among the four keys that cross the low level line and the four line lines. If all the column lines are high, no key is pressed in the keyboard.

2. Determine the position of the closed key. After confirming that the key is pressed, you can enter the process of determining the specific close key. The method is: sequentially setting the row line to a low level, that is, when a certain row line is low, the other lines are high. After determining that a certain row line position is low, the level state of each column line is detected line by line. If a column is low, the button at the intersection of the column line and the line line that is set low is the closed button.

<2> Determining which key on the matrix keyboard is pressed introduces a "high and low level flip method".

First, let the P1 port be four high and the lower four bits be 0. If there is a button press, one of the upper four digits will be flipped to 0, and the lower four digits will not change. At this point, the row position of the pressed key can be determined.

Then let the P1 port be four digits high and the lower four digits. If there is a button press, one of the lower four digits will be flipped to 0, and the upper four digits will not change. At this point, the column position of the pressed key can be determined.

Finally, the two are ORed to determine the position of the pressed key.

For more information on matrix keyboards, please visit http://

It applies to the horizontal and vertical low-power wind generator of 100W to 600W. This type Controller has strong compatibility and a great various protection functions, have more 10 years of application practice to improve performance continuously to make it has high reliable and stability. It can be used to the street lighting, monitoring system, outdoor advertisement, home type generation system etc.

Wind Turbine Controller

Wind Turbine Controller,Motor Controller,Automatic Control Controller,Charge Controller

Delight Eco Energy Supplies Co., Ltd. , https://www.cndelight.com