Determining which keys on a matrix keyboard are pressed introduces a “line scan method”.
Row scan method Row scan method, also known as row by row (or column) scan query method, is a commonly used key recognition method. The introduction process is as follows.
1. Determine whether there is a key pressed on the keyboard Set all row lines Y0-Y3 to low level, and then detect the state of the column line. As long as the level of one column is low, it means that a key is pressed on the keyboard, and the closed key is located among the 4 keys where the low level line intersects with the 4 row lines. If all column lines are high, no key is pressed in the keyboard.
2. Determine the position of the closed key After confirming that there is a key pressed, you can enter the process of determining the specific closed key.
The method is as follows: the row lines are set to the low level in turn, that is, when a certain row line is set to the low level, the other lines are set to the high level. After the position of a row line is determined to be low level, the level state of each column line is detected row by row. If a column is low, the button at the intersection of the column line and the row line set to low is the closed button.