CN103294214B - A kind of keyboard matrix scanning system of saving I/O - Google Patents
A kind of keyboard matrix scanning system of saving I/O Download PDFInfo
- Publication number
- CN103294214B CN103294214B CN201310186702.9A CN201310186702A CN103294214B CN 103294214 B CN103294214 B CN 103294214B CN 201310186702 A CN201310186702 A CN 201310186702A CN 103294214 B CN103294214 B CN 103294214B
- Authority
- CN
- China
- Prior art keywords
- row
- press
- keyboard matrix
- port value
- button
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Abstract
Save a keyboard matrix scanning system of I/O, relate to a kind of scanning system, described system comprises 4 × 5 metal keyboard matrixes or 5 × 5 keyboard matrixs and circuit and forms, and its diode circuit comprises M I/O and scans M × N keyboard matrix; 4 I/O are provided with in 4 × 5 keyboard matrix sweep circuits; 5 I/O are provided with in 5 × 5 keyboard matrix sweep circuits.First carry out initialization, then start to scan each row, from the 1st row, judge whether the 1st row has key to press according to port value, if there is button to press, after returning key assignments, terminate program; In engineering project of the present invention, keyboard matrix controls, and can reduce the complexity of programming, and it is cost-saving to reduce chip.Reduce programming difficulty.Only increase a small amount of diode in circuit, M I/O can be realized and scan M × N( M≤N) keyboard matrix.Circuit structure is simple, software programming is easy, can widely use in low cost circuit.
Description
Technical field
The present invention relates to a kind of scanning system, particularly relate to a kind of keyboard matrix scanning system of saving I/O.
Background technology
In engineering project, the normal keyboard matrix that adopts controls.To a M × N(
) keyboard matrix, conventional scan method needs M+N I/O to carry out line scanning respectively and column scan determines which button concrete is pressed.In most of project, microcontroller is often connected with multiple peripherals, as keyboard matrix, liquid crystal, EEPROM, RFIC, time chip, communication chip, analog to digital converter chip, multi-way switch etc.Only keyboard matrix just takies M+N I/O, and for the less single-chip microcomputer of I/O mouth as 51 series monolithics (having 4 I/O mouths), I/O shortage of resources is a unavoidable problem.In order to solve this problem, deviser it is envisioned that adopts chip to carry out expansion I/O mouth at first.But this method not only can improve programming complexity and also increase chip just mean increase cost.For for the inexpensive greatly manufacturer won victory of amount, this method is inadvisable.Second method increases microcontroller chip, but need between microcontroller to communicate, and increases programming difficulty.The third method changes microcontroller, adopts the microcontroller of more I/O mouth.This means early stage the hardware design of several months and software program all by irrevocably lost, project will restart, and this is also that deviser does not want to see.
For 4 × 5 metal keyboard matrixes conventional in project, conventional keyboard matrix sweep circuit as shown in Figure 1.This sweep circuit needs 9 I/O altogether.First carry out line scanning to circuit, make P0.3-P0.0 be low level, P0.7-P0.4, P1.0 are high level.If there is button to press, the row of its correspondence are dragged down.As SW11 press time, P0.4 is dragged down.Now, scan1=P0=11100000.Then, carry out column scan, make P0.7-P0.4, P1.0 be low level, P0.3-P0.0 is high level.If there is button to press, the row of its correspondence is dragged down.As SW11 press time, P0.0 is dragged down.Now, scan2=P0=00001110.In conjunction with the result scan=scan1|scan2=11101110 of row, column scanning.Can judge which button concrete is pressed according to the result of scan.
Summary of the invention
The object of the present invention is to provide a kind of keyboard matrix scanning system of saving I/O, this system only increases a small amount of diode in circuit, can realize M I/O and scan M × N(
) keyboard matrix.Circuit structure is simple, software programming is easy, can widely use in low cost circuit.
The object of the invention is to be achieved through the following technical solutions:
Save a keyboard matrix scanning system of I/O, described system comprises 4 × 5 metal keyboard matrixes or 5 × 5 keyboard matrixs and circuit and forms, and its diode circuit comprises M I/O and scans M × N keyboard matrix; 4 I/O are provided with in 4 × 5 keyboard matrix sweep circuits; 5 I/O are provided with in 5 × 5 keyboard matrix sweep circuits.
Described a kind of keyboard matrix scanning system of saving I/O, the program that described system 4 × 5 keyboard matrix sweep circuit is corresponding is:
First carry out initialization, then start to scan each row, from the 1st row, judge whether the 1st row has key to press according to port value, if there is button to press, after returning key assignments, terminate program; If the 1st row does not have button to press, start to scan the 2nd row; Judge whether the 2nd row has key to press according to port value, if there is button to press, after returning key assignments, terminate program; If the 2nd row does not have button to press, start to scan the 3rd row; Judge whether the 3rd row has key to press according to port value, if there is button to press, after returning key assignments, terminate program; If the 3rd row does not have button to press, start to scan the 4th row; Judge whether the 4th row has key to press according to port value, if there is button to press, after returning key assignments, terminate program, if the 4th row does not have button to press, terminate program.
Described a kind of keyboard matrix scanning system of saving I/O, described initialization, comprises port definition and array define.
According to port value, described a kind of keyboard matrix scanning system of saving I/O, describedly judges whether the 1st row has key to press, the port value that its SW11, SW12, SW13, SW14, SW15 are corresponding is 0x0c, 0x08,0x02,0x0a, 0x04.
According to port value, described a kind of keyboard matrix scanning system of saving I/O, describedly judges whether the 2nd row has key to press, the port value that its SW21, SW22, SW23, SW24, SW25 are corresponding is 0x0c, 0x09,0x01,0x08,0x05.
According to port value, described a kind of keyboard matrix scanning system of saving I/O, describedly judges whether the 3rd row has key to press, the port value that its SW31, SW32, SW33, SW34, SW35 are corresponding is 0x08,0x09,0x03,0x0a, 0x01.
According to port value, described a kind of keyboard matrix scanning system of saving I/O, describedly judges whether the 4th row has key to press, the port value that its SW41, SW42, SW43, SW44, SW45 are corresponding is 0x04,0x01,0x03,0x02,0x05.
Advantage of the present invention and effect are:
In engineering project of the present invention, keyboard matrix controls, and can reduce the complexity of programming, and it is cost-saving to reduce chip.Reduce programming difficulty.Only increase a small amount of diode in circuit, M I/O can be realized and scan M × N(
) keyboard matrix.Circuit structure is simple, software programming is easy, can widely use in low cost circuit.
Accompanying drawing explanation
Fig. 1 is 4 × 5 conventional metal keyboard matrix-scanning circuit diagrams;
Fig. 2 is the present invention 4 × 5 keyboard matrix sweep circuit figure;
Fig. 3 is the present invention 5 × 5 keyboard matrix sweep circuit figure;
Fig. 4 is 4 × 5 keyboard matrix sweep circuit process flow diagrams.
Embodiment
Below in conjunction with embodiment, the present invention is described in detail.
Fig. 2 is the present invention 4 × 5 keyboard matrix sweep circuit figure; Increase by 10 diodes in circuit, only need 4 I/O.Compared with 4 × 5 traditional keyboard matrix sweep circuits, required I/O number reduces by 5, is only 44.4% of custom circuit.This is for the less single-chip microcomputer of I/O number, and the I/O of reduction is considerable.
Circuit carries out a point line scanning: during scanning the 1st row, make P0.0 be low level, P0.1, P0.2, P0.3 are high level, i.e. P0.0=0, P0.1=P0.2=P0.3=1.If SW11 presses, diode D21 conducting, drags down P0.1.If SW12 presses, diode D22, D31 conducting, drags down P0.1, P0.2.If SW13 presses, diode D32, D41 conducting, drags down P0.2, P0.3.If SW14 presses, diode D33 conducting, drags down P0.2.If SW15 presses, diode D23, D42 conducting, drags down P0.1, P0.3.When scanning the 2nd row, make P0.1 be low level, P0.0, P0.2, P0.3 are high level, i.e. P0.1=0, P0.0=P0.2=P0.3=1.If SW21 presses, diode D11 conducting, drags down P0.0.If SW22 presses, diode D31 conducting, drags down P0.2.If SW23 presses, diode D32, D41 conducting, drags down P0.2, P0.3.If SW24 presses, diode D12, D33 conducting, drags down P0.0, P0.2.If SW25 presses, diode D42 conducting, drags down P0.3.When scanning the 3rd row, make P0.2 be low level, P0.0, P0.1, P0.3 are high level, i.e. P0.2=0, P0.0=P0.1=P0.3=1.If SW31 presses, diode D11, D21 conducting, drags down P0.0, P0.1.If SW32 presses, diode D22 conducting, drags down P0.1.If SW33 presses, diode D41 conducting, drags down P0.3.If SW34 presses, diode D12 conducting, drags down P0.0.If SW35 presses, diode D23, D42 conducting, drags down P0.1, P0.3.When scanning the 4th row, make P0.3 be low level, P0.0, P0.1, P0.2 are high level, i.e. P0.3=0, P0.0=P0.1=P0.2=0.If SW41 presses, diode D11, D21 conducting, drags down P0.0, P0.1.If SW42 presses, diode D22, D31 conducting, drags down P0.1, P0.2.If SW43 presses, diode D32 conducting, drags down P0.2.If SW44 presses, diode D12, D33 conducting, drags down P0.0, P0.2.If SW45 presses, diode D23 conducting, drags down P0.1.In sum, the course of work of circuit is as shown in table 1.
Table 14 × 5 keyboard matrix sweep circuit exports
The keyboard matrix sweep circuit that Fig. 2 proposes also can be applicable to 5 × 5 keyboard matrixs, and its circuit as shown in Figure 3.Compared with Fig. 2, increase only an I/O.Circuit working process is as shown in table 2.Fig. 2,3 demonstrates sweep circuit in this paper only can scan M × N(with M I/O
) keyboard matrix.
Table 25 × 5 keyboard matrix sweep circuit exports
The present invention 4 × 5 keyboard matrix sweep circuit program as shown in Figure 4.At the beginning of program, carry out initialization, comprise port definition and array define.Then start to scan each row, from the 1st row.Judge whether the 1st row has key to press (port value that SW11, SW12, SW13, SW14, SW15 are corresponding is 0x0c, 0x08,0x02,0x0a, 0x04) according to port value.If there is button to press, after returning key assignments, terminate program.If the 1st row does not have button to press, start to scan the 2nd row.Judge whether the 2nd row has key to press (port value that SW21, SW22, SW23, SW24, SW25 are corresponding is 0x0c, 0x09,0x01,0x08,0x05) according to port value.If there is button to press, after returning key assignments, terminate program.If the 2nd row does not have button to press, start to scan the 3rd row.Judge whether the 3rd row has key to press (port value that SW31, SW32, SW33, SW34, SW35 are corresponding is 0x08,0x09,0x03,0x0a, 0x01) according to port value.If there is button to press, after returning key assignments, terminate program.If the 3rd row does not have button to press, start to scan the 4th row.Judge whether the 4th row has key to press (port value that SW41, SW42, SW43, SW44, SW45 are corresponding is 0x04,0x01,0x03,0x02,0x05) according to port value.If there is button to press, after returning key assignments, terminate program.If the 4th row does not have button to press, terminate program.
Claims (1)
1. save a keyboard matrix scanning system of I/O, it is characterized in that, described system comprises 4 × 5 metal keyboard matrixes or 5 × 5 keyboard matrixs and circuit and forms, and its diode circuit comprises M I/O and scans M × N keyboard matrix; 4 I/O are provided with in 4 × 5 keyboard matrix sweep circuits; 5 I/O are provided with in 5 × 5 keyboard matrix sweep circuits; The program that described system 4 × 5 keyboard matrix sweep circuit is corresponding is:
First carry out initialization, then start to scan each row, from the 1st row, judge whether the 1st row has key to press according to port value, if there is button to press, after returning key assignments, terminate program; If the 1st row does not have button to press, start to scan the 2nd row; Judge whether the 2nd row has key to press according to port value, if there is button to press, after returning key assignments, terminate program; If the 2nd row does not have button to press, start to scan the 3rd row; Judge whether the 3rd row has key to press according to port value, if there is button to press, after returning key assignments, terminate program; If the 3rd row does not have button to press, start to scan the 4th row; Judge whether the 4th row has key to press according to port value, if there is button to press, after returning key assignments, terminate program, if the 4th row does not have button to press, terminate program; Described initialization, comprises port definition and array define; Describedly judge whether the 1st row has key to press according to port value, the port value that its SW11, SW12, SW13, SW14, SW15 are corresponding is 0x0c, 0x08,0x02,0x0a, 0x04; Describedly judge whether the 2nd row has key to press according to port value, the port value that its SW21, SW22, SW23, SW24, SW25 are corresponding is 0x0c, 0x09,0x01,0x08,0x05; Describedly judge whether the 3rd row has key to press according to port value, the port value that its SW31, SW32, SW33, SW34, SW35 are corresponding is 0x08,0x09,0x03,0x0a, 0x01; Describedly judge whether the 4th row has key to press according to port value, the port value that its SW41, SW42, SW43, SW44, SW45 are corresponding is 0x04,0x01,0x03,0x02,0x05.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310186702.9A CN103294214B (en) | 2013-05-20 | 2013-05-20 | A kind of keyboard matrix scanning system of saving I/O |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310186702.9A CN103294214B (en) | 2013-05-20 | 2013-05-20 | A kind of keyboard matrix scanning system of saving I/O |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103294214A CN103294214A (en) | 2013-09-11 |
CN103294214B true CN103294214B (en) | 2016-04-06 |
Family
ID=49095230
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310186702.9A Expired - Fee Related CN103294214B (en) | 2013-05-20 | 2013-05-20 | A kind of keyboard matrix scanning system of saving I/O |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103294214B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106018080A (en) * | 2016-05-12 | 2016-10-12 | 成都易创思生物科技有限公司 | Method for measuring Young modulus of metal |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN2669264Y (en) * | 2004-01-02 | 2005-01-05 | 广东科龙电器股份有限公司 | Keyboard scanning circuit |
CN101470527A (en) * | 2007-12-24 | 2009-07-01 | 深圳安凯微电子技术有限公司 | Keyboard circuit with reduced input/output export |
CN101860369A (en) * | 2010-06-24 | 2010-10-13 | 鸿富锦精密工业(深圳)有限公司 | Matrix keyboard and scanning method thereof |
CN102075194A (en) * | 2009-11-23 | 2011-05-25 | 鸿富锦精密工业(深圳)有限公司 | Circuit and method for scanning keyboard and electronic equipment |
CN202424694U (en) * | 2011-12-27 | 2012-09-05 | 福建鑫诺通讯技术有限公司 | Keyboard scanning circuit saving input/output (I/O) ports |
CN203352566U (en) * | 2013-05-20 | 2013-12-18 | 沈阳化工大学 | I/O port-saving keyboard matrix scanning system |
-
2013
- 2013-05-20 CN CN201310186702.9A patent/CN103294214B/en not_active Expired - Fee Related
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN2669264Y (en) * | 2004-01-02 | 2005-01-05 | 广东科龙电器股份有限公司 | Keyboard scanning circuit |
CN101470527A (en) * | 2007-12-24 | 2009-07-01 | 深圳安凯微电子技术有限公司 | Keyboard circuit with reduced input/output export |
CN102075194A (en) * | 2009-11-23 | 2011-05-25 | 鸿富锦精密工业(深圳)有限公司 | Circuit and method for scanning keyboard and electronic equipment |
CN101860369A (en) * | 2010-06-24 | 2010-10-13 | 鸿富锦精密工业(深圳)有限公司 | Matrix keyboard and scanning method thereof |
CN202424694U (en) * | 2011-12-27 | 2012-09-05 | 福建鑫诺通讯技术有限公司 | Keyboard scanning circuit saving input/output (I/O) ports |
CN203352566U (en) * | 2013-05-20 | 2013-12-18 | 沈阳化工大学 | I/O port-saving keyboard matrix scanning system |
Also Published As
Publication number | Publication date |
---|---|
CN103294214A (en) | 2013-09-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN202710975U (en) | Data acquisition device | |
CN103682470B (en) | Lead acid accumulator pressurization formation device and method thereof | |
CN103294214B (en) | A kind of keyboard matrix scanning system of saving I/O | |
CN203352566U (en) | I/O port-saving keyboard matrix scanning system | |
CN202364197U (en) | Button detection and LED control circuit | |
CN203670317U (en) | Pressure increasing device | |
CN104521407A (en) | Diaphragm type liquid fertilizer transportation controller | |
CN209145879U (en) | A kind of vacuum pump set of environmental protection and energy saving | |
CN110308707A (en) | Controller, intelligentized Furniture and key control method | |
CN204474822U (en) | The opener of bump cotton | |
CN201756725U (en) | Water supply control device for textile arrangement | |
CN208349417U (en) | A kind of hot water apparatus for controlling pump suitable for heating | |
CN202955753U (en) | Sleeve fixing structure of combustion chamber of camping stove | |
CN204716648U (en) | A kind of duplex pump hydraulic system | |
CN204143197U (en) | A kind of universal embedded hardware platform | |
CN204063871U (en) | Humid control drying unit | |
CN202391751U (en) | Device for connecting hydraulic press motor with pump | |
CN204476889U (en) | A kind of battery saving arrangement of PCB press equipment hydraulic system | |
CN201897932U (en) | Single-chip controller for LED (light-emitting diode) screen | |
CN206208408U (en) | A kind of novel greenhouse temperature acquisition monitoring system | |
CN207096326U (en) | A kind of intellectualizing system of intelligent electric meter | |
CN207568828U (en) | A kind of hydraulic axial plunger variable pump rear cover | |
CN206045894U (en) | A kind of efficient coating dispersion machine | |
CN207319859U (en) | Envelope angle Base top contact structure in furnace transformer low pressure | |
CN207106182U (en) | Automobile instrument claw attachment structure |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20160406 Termination date: 20190520 |
|
CF01 | Termination of patent right due to non-payment of annual fee |