A typical digital interface for a 4×4 keypad uses 8 digital I/O pins. But using 8 pins as digital I/O takes up the number of segment driver pins that can be used to connect to the LCD.
By using 2 digital I/O pins and 2 analog input pins, a 4×4 keypad can be added to a PIC microcontroller without sacrificing any of its LCD segment driver pins.
The following figure shows the keypad connections. A PIC18F8490 is used in the example, but the technique can be used with any LCDPIC MCU.
The two digital I/O pins used in the diagram are RBO and RB5, but any other two digital I/O pins can be used. The two analog pins used are ANO and AN1.
To read the keypad, follow these steps:
1. First, design RBO to output high level and RB5 to input (high impedance).
2. Perform two consecutive A/D conversions, first converting ANO and then converting AN1.
3. Save the conversion results into their respective variables: for example, RBO-ANO-Result and RBO-ANl-Result.
4. Then, set RB5 to output high level and RBO to input (high impedance).
5. Perform two consecutive A/D conversions, first converting ANO and then converting AN1.
6. Save the conversion results into their respective variables: for example, RB5-ANO-Result and RB5-ANl-Result.
7. Now, there are 4 variables, representing a key press in each quadrant of the 4×4 keypad:
8. Finally, check each value against the corresponding column in the table below. If it is within +/-10% of a certain value, the corresponding key can be considered to have been pressed.
9. This loop should be repeated approximately every 20ms. Do not forget to execute the key pop-up handler. For example, the key is considered pressed only when the above steps return the same key value twice in a row (with a 20ms delay in between). It is also required that the next key operation can only be started when no key is pressed at least twice. When several keys in the same quadrant are pressed at the same time, voltages other than the four valid levels shown in Table 3 may be generated. These levels can be ignored, or if you want to enable certain functions by using simultaneous key presses, you can also add a decoding process for these levels.
Previous article:PIC24FV16KM204 Series General Purpose 16-bit Flash MCU Data Sheet
Next article:Analysis of I/O Control Operations of PIC Microcontroller
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- Ultrasound patch can continuously and noninvasively monitor blood pressure
- Ultrasound patch can continuously and noninvasively monitor blood pressure
- Europe's three largest chip giants re-examine their supply chains
- Europe's three largest chip giants re-examine their supply chains
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Design of automotive LIN communication simulator based on Renesas MCU
- When will solid-state batteries become popular?
- Adding solid-state batteries, CATL wants to continue to be the "King of Ning"
- The agency predicts that my country's public electric vehicle charging piles will reach 3.6 million this year, accounting for nearly 70% of the world
- I bought a ZT303 multimeter.
- Add a startup program to the itop4412 development board
- Next-generation wireless network standard technology HiperLAN/2
- Products + DC brushless motor control + drive kit
- MSP430 SPI communication routine
- Recommend a low thermal potential relay
- LED transparent screen signal transmission method
- HOLTEK large table reading application and source code
- Electric water heater control panel
- MicroPython makes several more improvements to Bluetooth