interface lcd and keypad with 8051 micro
TRANSCRIPT
![Page 1: Interface Lcd and Keypad With 8051 Micro](https://reader038.vdocuments.us/reader038/viewer/2022100506/577c84921a28abe054b975d6/html5/thumbnails/1.jpg)
8/19/2019 Interface Lcd and Keypad With 8051 Micro
http://slidepdf.com/reader/full/interface-lcd-and-keypad-with-8051-micro 1/7
Interface lcd and keypad with 8051
microcontroller in C
Post on October 23, 2012 by Technology tagged: Interface lcd and keypad with 801
!icrocontroller , "i!#lation for Interface keypad with 801 !icrocontroller , "i!#lation for
Interface lcd and keypad with 801, "i!#lation for Interface lcd and keypad with 801!icrocontroller , "i!#lation for Interface lcd with 801
To interface lcd and keypad with 801 !icrocontroller in $ , we first need few hardware and a
software%Software : &o# need a co!piler, here i #sed a keil co!piler%&o# also #sed other $ co!piler%
Hardware : 'hen yo# done yo#r progra!!ing, yo# definitely want to see it in action% 'ell for
that we need so!e harware co!ponents%
1% (cd 1)*22% 801 !icroprocessor + I #sed t8-c1 of t!el
3% .eypad /*/
/% Two 33p $apacitors% One 0%1# $apacitor and 10k register
Interface lcd and keypad with 8051 microcontroller in C
language & Simulation
This post proides the keypad interfacing code #sing c lang#age for 801 !icro4controller e4g for T8-$1 or T8-$2 etc % This code is written in s#ch a way that, when we press any key
on the keypad then that al#e is displayed on the ($5%
![Page 2: Interface Lcd and Keypad With 8051 Micro](https://reader038.vdocuments.us/reader038/viewer/2022100506/577c84921a28abe054b975d6/html5/thumbnails/2.jpg)
8/19/2019 Interface Lcd and Keypad With 8051 Micro
http://slidepdf.com/reader/full/interface-lcd-and-keypad-with-8051-micro 2/7
Interface lcd and keypad #sing T8-$1
crystal of 11%0-2 67 is #sed here% &o# can #se any crystal al#e fro! 3 to 2/67 with
801% s we know that 801 !icro controller has an architect#re which e9ec#tes an instr#ctionin 12 $P cycles ;1<, hence this 11%0-26h crystal !akes this 801 r#n at 0%-2 6IP" 6illion
of instr#ctions per second%
Port 2 is being #sed to write data on the ($5% lso, P3%= pin is #sed as >" >egister "elect for
($5 and P3%) pin is #sed as ? ?nable pin for ($5% Port 1 is #sed here to interface the keypad%P1%0 to P1%3 pins are #sed for the rows and P1%/ to P1%= are #sed for the col#!ns of the keypad%
Interface Keypad with 8051 microcontroller in c language
How to detect preed key !alue "
'hen key 1 is pressed then >ow$ wire is shorted with $1 wire inside the keypad% "i!ilarly,when key - is pressed then >ow wire is shorted with $3 wire% This behaior is tr#e for all the
keys% Then the ne9t @#estion is, how to detect this behaior in the !icro4controller code A
![Page 3: Interface Lcd and Keypad With 8051 Micro](https://reader038.vdocuments.us/reader038/viewer/2022100506/577c84921a28abe054b975d6/html5/thumbnails/3.jpg)
8/19/2019 Interface Lcd and Keypad With 8051 Micro
http://slidepdf.com/reader/full/interface-lcd-and-keypad-with-8051-micro 3/7
'e can detect pressed key al#e in the !icro4controller #sing the B"canning lgorith! $odeC%
This algorith! is written with the na!e of D>?5E"'IT$7?"F f#nction in the code% This
f#nction is shown belowchar >?5E"'IT$7?"oid
G
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow >ow H 0
if $1 HH 0 G delay10000 while $1HH0 ret#rn F=L M
if $2 HH 0 G delay10000 while $2HH0 ret#rn F8L Mif $3 HH 0 G delay10000 while $3HH0 ret#rn F-L M
if $/ HH 0 G delay10000 while $/HH0 ret#rn DKF M
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow J
>owJ H 0if $1 HH 0 G delay10000 while $1HH0 ret#rn F/L M
if $2 HH 0 G delay10000 while $2HH0 ret#rn FL M
if $3 HH 0 G delay10000 while $3HH0 ret#rn F)L Mif $/ HH 0 G delay10000 while $/HH0 ret#rn D9F M
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow $
>ow$ H 0
if $1 HH 0 G delay10000 while $1HH0 ret#rn F1L Mif $2 HH 0 G delay10000 while $2HH0 ret#rn F2L M
if $3 HH 0 G delay10000 while $3HH0 ret#rn F3L M
if $/ HH 0 G delay10000 while $/HH0 ret#rn D4F M
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow 5
>ow5 H 0if $1 HH 0 G delay10000 while $1HH0 ret#rn D$F M
if $2 HH 0 G delay10000 while $2HH0 ret#rn F0L M
if $3 HH 0 G delay10000 while $3HH0 ret#rn DHF Mif $/ HH 0 G delay10000 while $/HH0 ret#rn DNF M
ret#rn DnF KK 6eans no key has been pressed
M
Interface lcd and keypad with 8051 microcontroller in C language
Complete #rogram :
incl#de
incl#de
KK#nction declarations
oid cctEinitoid
oid delay#nsigned int
![Page 4: Interface Lcd and Keypad With 8051 Micro](https://reader038.vdocuments.us/reader038/viewer/2022100506/577c84921a28abe054b975d6/html5/thumbnails/4.jpg)
8/19/2019 Interface Lcd and Keypad With 8051 Micro
http://slidepdf.com/reader/full/interface-lcd-and-keypad-with-8051-micro 4/7
![Page 5: Interface Lcd and Keypad With 8051 Micro](https://reader038.vdocuments.us/reader038/viewer/2022100506/577c84921a28abe054b975d6/html5/thumbnails/5.jpg)
8/19/2019 Interface Lcd and Keypad With 8051 Micro
http://slidepdf.com/reader/full/interface-lcd-and-keypad-with-8051-micro 5/7
writedatas
sNN
MM
oid 7o!eoidG
writec!d0902delay200
M
oid cctEinitoid
GP0 H 0900 KKnot #sed
P1 H 09f0 KK#sed for generating o#tp#ts and taking inp#ts fro! .eypad
P2 H 0900 KK#sed as data port for ($5
P3 H 0900 KK#sed for >" and ?M
oid delay#nsigned int a
Gint i
foriH0i
M
oid writedatachar tG
>" H 1 KK This is dataP2 H t KK5ata transfer ? H 1
delay10
? H 0delay10
M
oid writec!dint
G>" H 0 KK This is co!!and
P2 H KK5ata transfer
? H 1delay10
? H 0
delay10
M
![Page 6: Interface Lcd and Keypad With 8051 Micro](https://reader038.vdocuments.us/reader038/viewer/2022100506/577c84921a28abe054b975d6/html5/thumbnails/6.jpg)
8/19/2019 Interface Lcd and Keypad With 8051 Micro
http://slidepdf.com/reader/full/interface-lcd-and-keypad-with-8051-micro 6/7
oid lcdinitoid
G
delay1000writec!d0930
delay/00writec!d0930
delay300writec!d0930
delay)0
writec!d0938 KKf#nction set
writec!d090f KKdisplay on,c#rsor off,blink onwritec!d0901 KKclear display
writec!d090) KKentry !ode, set incre!ent
M
char >?5E"'IT$7?"oid
G
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow
>ow H 0if $1 HH 0 G delay10000 while $1HH0 ret#rn = M
if $2 HH 0 G delay10000 while $2HH0 ret#rn 8 M
if $3 HH 0 G delay10000 while $3HH0 ret#rn - Mif $/ HH 0 G delay10000 while $/HH0 ret#rn K M
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow J
>owJ H 0if $1 HH 0 G delay10000 while $1HH0 ret#rn / Mif $2 HH 0 G delay10000 while $2HH0 ret#rn M
if $3 HH 0 G delay10000 while $3HH0 ret#rn ) M
if $/ HH 0 G delay10000 while $/HH0 ret#rn 9 M
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow $>ow$ H 0
if $1 HH 0 G delay10000 while $1HH0 ret#rn 1 M
if $2 HH 0 G delay10000 while $2HH0 ret#rn 2 Mif $3 HH 0 G delay10000 while $3HH0 ret#rn 3 M
if $/ HH 0 G delay10000 while $/HH0 ret#rn 4 M
>ow H 1 >owJ H 1 >ow$ H 1 >ow5 H 1 KKTest >ow 5
>ow5 H 0if $1 HH 0 G delay10000 while $1HH0 ret#rn $ M
if $2 HH 0 G delay10000 while $2HH0 ret#rn 0 M
if $3 HH 0 G delay10000 while $3HH0 ret#rn H Mif $/ HH 0 G delay10000 while $/HH0 ret#rn N M
![Page 7: Interface Lcd and Keypad With 8051 Micro](https://reader038.vdocuments.us/reader038/viewer/2022100506/577c84921a28abe054b975d6/html5/thumbnails/7.jpg)
8/19/2019 Interface Lcd and Keypad With 8051 Micro
http://slidepdf.com/reader/full/interface-lcd-and-keypad-with-8051-micro 7/7