PIC18F8490 microcontroller can be used to connect LCD segment driver design

Publisher:梦想学院Latest update time:2019-12-27 Source: elecfansKeywords:PIC18F8490 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

PIC18F8490 microcontroller can be used to connect LCD segment driver design

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:

PIC18F8490 microcontroller can be used to connect LCD segment driver design

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.

PIC18F8490 microcontroller can be used to connect LCD segment driver design

Keywords:PIC18F8490 Reference address:PIC18F8490 microcontroller can be used to connect LCD segment driver design

Previous article:PIC24FV16KM204 Series General Purpose 16-bit Flash MCU Data Sheet
Next article:Analysis of I/O Control Operations of PIC Microcontroller

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号