0% found this document useful (0 votes)
299 views15 pages

LCD and Keyboard Interfacing

This document discusses keyboard interfacing with the 8051 microcontroller. It describes how keyboards use a matrix of rows and columns to detect key presses. A microcontroller in the keyboard scans the keys continuously to identify which key is activated and send it to the motherboard. It then discusses how a 4x4 keypad can be connected to the 8051 ports and scanned to detect key presses by outputting rows high and low and reading the column inputs. The document also covers debouncing, which is needed because mechanical switch contacts bounce upon pressing and require time to settle, and could register as multiple key presses. It provides examples of hardware and software debouncing techniques.

Uploaded by

Ammar Ehab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
299 views15 pages

LCD and Keyboard Interfacing

This document discusses keyboard interfacing with the 8051 microcontroller. It describes how keyboards use a matrix of rows and columns to detect key presses. A microcontroller in the keyboard scans the keys continuously to identify which key is activated and send it to the motherboard. It then discusses how a 4x4 keypad can be connected to the 8051 ports and scanned to detect key presses by outputting rows high and low and reading the column inputs. The document also covers debouncing, which is needed because mechanical switch contacts bounce upon pressing and require time to settle, and could register as multiple key presses. It provides examples of hardware and software debouncing techniques.

Uploaded by

Ammar Ehab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

LCD AND KEYBOARD

INTERFACING(2)
KEYBOARD
INTERFACING
Interfacing the keyboard to the 8051
• At the lowest level, keyboards are organized in a matrix of rows and
columns.
• In IBM PC keyboards, a single microcontroller (consisting of a
microprocessor, RAM and EPROM, and several ports all on a single
chip) takes care of hardware and software interfacing of the keyboard.
• The microcontroller scans the keys continuously, identify which one
has been activated, and present it to the motherboard.
4x4 keypad
Scanning and identifying the key

• 4x4 Matrix Keyboard


Connection to Ports
A key press detection and identification
• A key press detection
• OUT =0000  INPUT = ?  = 1111 (no key pressed), other wise (a key
pressed)
• Identify the pressed key
• OUT =1110  INPUT = ?  = 1111 (no key pressed), otherwise the
column with a 0 identify the pressed key
• The process is repeated with other rows.
Mechanical switches are used as keys in most of the keyboards. When a key is
pressed the contact bounce back and forth and settle down only after a small time
delay (about 20ms). Even though a key is actuated once, it will appear to have been
actuated several times. This problem is called Key Bouncing.

http://www.labbookpages.co.uk/electronics/debounce.html
Hardware Key de-bouncing
(circuit examples)
MM74C922 • MM74C923
16-Key Encoder • 20-Key Encoder
Block Diagram
Truth Tables
Software De-bouncing
• After the key press detection, the microcontroller waits 20 ms for the
bounce and then scans the columns again
• This serves two functions: (a) it ensures that the first key press
detection was not an erroneous one due to a spike noise, and (b) the
20-ms delay prevents the same key press from being interpreted as a
multiple key press.
• If after the 20-ms delay the key is still pressed, it goes to the next
stage to detect which row it belongs to; otherwise, it goes back into
the loop to detect a real key press.
Accessing code data space in 8051 C
• In all our 8051 C examples so far, byte-size variables were stored in
the 128 bytes of RAM.
• To make the C compiler use the code space instead of the RAM space,
we need to put the keyword code in front of the variable declaration.
• Example:
code unsigned char mynum[] = "012345ABCD"; //use code space
code unsigned char weekdays=7, month=12; //use code space

You might also like