button
There are two commonly used key circuits, one is an independent key and the other is a matrix key.
Independent buttons
The independent buttons are each connected to an independent input line.
Take the circuit in the following figure as an example for analysis.
Independent button schematic diagram:
The basis for judging whether a key is pressed is: the level of the KeyIn (n) IO port.
When K1 is pressed, the high and low level ends of the circuit are connected. At this time, the Keyln1 pin is at a low level.
When K1 is released, the line is disconnected, Keyln1 and +5V are at the same potential, and the Keyln1 pin is at a high level.
Usually, there is a pull-up resistor inside the IO port of the microcontroller.
Take the quasi-bidirectional IO port structure diagram as an example:
The circuit inside the box is the internal part of the microcontroller, and outside the box are the external pull-up resistors and buttons.
Note: When reading external key signals, the microcontroller must first set the pin to 1! ! !
analyse as below:
When the internal output = 1, it is inverted to 0 after the NOT gate, the NPN transistor has no potential difference, and the circuit is not connected. There is no potential difference between VCC (also +5V) and +5V, and the IO port of the microcontroller is at a high level. The key status can be read normally.
When the internal output = 0, it is inverted to 1, the NPN transistor generates a potential difference, and the circuit is connected. The IO port of the microcontroller is affected and becomes a low level, and the key status cannot be read normally.
Matrix Buttons
Based on independent buttons, in order to improve the utilization rate of IO ports, matrix buttons came into being.
As shown in the figure, 8 IO ports realize 16 buttons.
If KeyOut1 outputs a low level, KeyOut1 is equivalent to GND, and the other four keys are equivalent to independent keys. It should be noted that KeyOut2, KeyOut3 and KeyOut4 should all output a high level at this time to avoid affecting the KeyOut1 line.
The circuit diagram is now simplified to this:
Previous article:#51 MCU#Key debounce
Next article:#51 MCU#Interrupt and digital tube application
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Come quickly: Buy multimeters and development boards for 11.11 yuan, a Double 11 feast for new element11 users~
- Recommended RF front-end chips for mobile phones in the 5G era
- The Linux Foundation expects revenue to reach $177 million this year
- What does PAD mean in a circuit schematic?
- September 23 nexperia live broadcast review: Nexperia's efficient ESD solutions for connected car applications
- Knowledge of common op amp models
- These two methods make electric vehicles run farther in winter
- Voltage Follower
- Anlu SparkRoad Development Board Review (1) Development Board Hardware Overview
- C Data Structures