When developing a single-chip microcomputer project, keyboards are often needed, and most of the time, keyboards use single-button or matrix keyboards. Matrix keyboards have many advantages, and I won't go into details here, but one thing is that a few more buttons will waste the port line, especially when the keyboard needs to be led out, the long and long lines are very annoying. Next, I will talk about the design and implementation of a two-wire multi-button circuit. The keyboard only needs two wires, provided that your single-chip microcomputer system has an extra AD port line. At this point, someone will ask, my system does not use analog acquisition, and I have to add an AD chip to get this keyboard. Isn't this a loss of the greater for the less? What I want to say is that there are quite a lot of single-chip microcomputers with AD functions now, and the price is not much more expensive than those without. Of course, if you choose one without AD, it's another matter.
I encountered several situations when I was working on a project key: 1. The product has many peripherals, and the microcontroller I/O port has only one I/O port except the keyboard, and there is no extra one; 2. Due to the limitations of the site, the keyboard and the motherboard must be a certain distance away; 3. The keyboard needs 9 keys. According to the above situation, a two-wire keyboard is the most suitable. The circuit is shown in the figure.
Some buttons are omitted in the figure, and you can configure the buttons according to your actual needs. At this time, you can scan and read through AD, and judge whether a button is pressed or which button is pressed according to the AD value. According to the resistance value in the above figure (for the convenience of example, all values are 1K, you can choose other resistance values, and the voltage is evenly distributed as much as possible), you can calculate: if no button is pressed, the AD value is VCC; S1 is pressed, the AD value is 0; S2 is pressed, the AD value is 1/2VCC; similarly, S3=2/3VCC; S4=3/4VCC; S5=4/5VCC; according to the AD acquisition value, the key value that is closest to it is the key.
There are a few points to note when using this method: 1. Do not have too many buttons, which is related to the AD resolution, otherwise the detection will be inaccurate. For example, with an 8-bit resolution, there are 256 points in total, and it is best if each button has more than 25 points. That is, 256/25=10, a maximum of 10 buttons. You can experiment on your own.
2. Choose buttons with good contact. Poorly-made buttons will easily generate contact resistance after a long period of use, and multiple buttons are prone to misdetection.
Previous article:Realization of radio simulation training system based on single chip microcomputer
Next article:Improved float type liquid level meter based on MSP430F133 single chip microcomputer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Microcontrollers: The Basics
- Improvement of RC series-parallel frequency-selective network oscillator in El experimental box
- Texas Instruments helps you solve the three most common problems in high-speed amplifier design!
- LNA [Low Noise Amplifier Practical Application Case]——[qorvo-TQL9092]
- Solutions to security issues in RF systems and Wi-Fi networks
- [ESP32-S2-Kaluga-1 Review] 2. LCD display pictures
- 【Video Class】Introduction to Antenna Eigenmode Analysis
- Can't see the downloaded file
- 【AT-START-F425 Review】No.05 FLASH
- Recommend several introductory books on the Internet of Things