Professional Documents
Culture Documents
Elec n267 - 8051 KBD&LCD
Elec n267 - 8051 KBD&LCD
&
Liquid Crystal Display (LCD)
Hex KeyBoard (KBD)
• When a key is pressed, the coressponding Hex key-code value is
generated by the KBD on A,B, C and D lines.
• The F line (Flag) is HIGH (5V) as long as a key is being pressed and
goes LOW (0V) when the key is released .
• Example:
Key “3” is being pressed then
F D C B A
VCC
1 0 0 1 1 0 1 2 3
A
Key “3” is being released then B
4 5 6 7
F D C B A C
0 0 0 1 1 8 9 A B
D
G
Key “B” is being pressed then
F
F D C B A C D E F
1 1 0 1 1
Key “B” is being released then
F D C B A
0 1 0 1 1
Hex KeyBoard (KBD)
Example: This program accepts 2 numbers from the KBD add them and
store the result in register R1.
ORG 00H
SJMP MAIN
ORG 30H
+5v
MAIN: MOV A , #0FFH
VCC
MOV P2, A 0 1 2 3
A P2.0
LCALL GET_KEY B P2.1 8051
4 5 6 7
MOV B,A C P2.2
D P2.3
LCALL GET_KEY 8 9 A B
G
ADD A,B
F P2.4
MOV R1 , A C D E F
ORG 50H
GET_KEY: JNB P2.4 , GET_KEY
MOV A , P2
ANL A , #0FH
RET
END
Liquid Crystal Display (LCD)
• LCD is a device to display numbers, characters and graphics.
Line 1 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
Line 2 C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 E R/W RS VEE VCC VSS BKL+ BKL-
14 13 12 11 10 9 8 7 6 5 4 3 2 1 15 16
Liquid Crystal Display (LCD)
• LCD has 2 lines, each line has 16 locations (positions). Each location
has a unique address (number).
• Once the LCD is configured. Characters and /or numbers (Data) can
be sent to the LCD for display.