1, design principle
(1) As shown in Figure 14.2, connect the 4&TImes; 4 matrix keyboard with the parallel port P3 of the MCU, and use the P3.0-P3.3 pins of the MCU as the input line to P3.4-P3.7 of the MCU. Each pin is used as an output line, and the serial number of each button "0-F" is displayed on the digital tube.
(2) The serial number of the corresponding button in the keyboard is shown in Figure 14.1.
2, the reference circuit
Figure 14.2 4 & TImes; 4 matrix keyboard recognition circuit schematic
3, circuit hardware description
(1) In the "Single-chip system" area, connect the P3.0-P3.7 port of the MCU to the M1-M4, N1- in the "4&TImes; 4 determinant keyboard" area via the 8-Dial DIP switch JP3. On the N4 port.
(2) In the "Single-chip system" area, connect the P0.0-P0.7 port of the MCU to any ah port in the "Static Digital Display Module" area; Requirement: P0.0 corresponds to a, P0. 1 corresponds to b, ..., P0.7 corresponds to h.
4, programming content
(1) 4 & TImes; 4 matrix keyboard recognition processing.
(2) Each button has its row and column values. The combination of row and column values ​​is the code that identifies the button. The row and column lines of the matrix communicate with the CPU through two parallel interfaces, respectively. One end of the keyboard (column line) is connected to VCC through a resistor, and the grounding is realized by the program output number "0". The task of the keyboard handler is to determine if there is a key press, to determine which key is pressed, what is the function of the key, and to eliminate the jitter of the key when it is closed or disconnected. Among the two parallel ports, one output scan code makes the button dynamically grounded line by line; the other parallel port inputs the button state, and the line scan value and the feedback signal form a key code to identify the button, and the key is detected by software to find the key. Features.
5, the program flow chart (as shown in Figure 14.3)
Our company specializes in the production and sales of all kinds of terminals, copper terminals, nose wire ears, cold pressed terminals, copper joints, but also according to customer requirements for customization and production, our raw materials are produced and sold by ourselves, we have their own raw materials processing plant, high purity T2 copper, quality and quantity, come to me to order it!
Cable Terminals
Taixing Longyi Terminals Co.,Ltd. , https://www.lycopperlugs.com