SlideShare a Scribd company logo
EN equ P2.0
RS equ P2.1
RW equ P2.2
mov A,#38H ; Setting Up the LCD
lcall command
mov A,#0EH ; Display On
lcall command
mov A,#06H ; Entry Mode
lcall command
mov a,#82H
lcall command
lcall disp ; Function Disp Called
mov a,#02H ; Setting DDRAM Address to Home position
lcall command
lcall delay1
; Displays BOTSKOOL SHOBHIT ON FIRST LINE OF LCD
mov a,#'B'
lcall datw
NOP
mov a,#'0'
lcall datw
NOP
mov a,#'T'
lcall datw
mov a,#'S'
lcall datw
NOP
mov a,#'K'
lcall datw
NOP
mov a,#'0'
lcall datw
NOP
mov a,#'0'
lcall datw
NOP
mov a,#'L'
lcall datw
NOP
mov a,#' '
lcall datw
NOP
mov a,#'S'
lcall datw
NOP
mov a,#'H'
lcall datw
NOP
mov a,#'O'
lcall datw
NOP
mov a,#'B'
lcall datw
NOP
mov a,#'H'
lcall datw
NOP
mov a,#'I'
lcall datw
NOP
mov a,#'T'
lcall datw
MOV A,#255 ; Moving Value 255 to PORT 3
MOV P3,A
; Keypad Scan Begins
sd:
lcall delay1
lcall key1
lcall delay
lcall key2
lcall delay
lcall key3
lcall delay
lcall key4
lcall delay
lcall sd
; Function to Send Commands to LCD
command:
clr RW
clr RS
setB EN
MOV P1,A
lcall delay
clr EN
RET
; Function to Clear the DDRAM Content
clear:
mov A,#01H
lcall command
lcall delay
mov A,#02H ; Set The DDRAM Address to Home Position
lcall command
lcall delay
RET
; Function to Display Data on LCD Screen
datw:
SETB RS
clr RW
SETB EN
MOV P1,A
lcall delay
clr EN
RET
;Function to Display The Key Pressed
datw1:
lcall delay1
lcall disp
lcall delay1
MOV A,R7
lcall datw
RET
; Generating Small Delay
delay:
mov r0,#255
loop: DJNZ r0,loop;
RET
; Generating a Bigger Delay
delay1:
mov r1,#255
loop1: mov r3,#120
loop2: djnz r3,loop2
djnz r1,loop1
RET
; Checking for Key Press on The First Column of 4x4 Matrix
KEY1:
MOV A,r5
MOV r6,A
clr p3.4
MOV A,p3
ANL A,#0FH
MOV r2,A
cjne r2,#14,n1
MOV r7,#'1'
lcall datw1
lcall delay1
n1: cjne r2,#13,n2
mov r7,#'5'
lcall datw1
lcall delay1
n2: cjne r2,#11,n3
mov r7,#'9'
lcall datw1
lcall delay1
n3: cjne r2,#7,n4
mov r7,#'D'
lcall datw1
lcall delay1
n4: lcall delay1
SETB P3.4
RET
; Checking for Key Press on the Second Column of 4x4 Matrix
KEY2:
clr p3.5
MOV A,p3
ANL A,#0FH
MOV r2,A
cjne r2,#14,q1
mov r7,#'2'
lcall datw1
lcall delay1
q1: cjne r2,#13,q2
mov r7,#'6'
lcall datw1
lcall delay1
q2: cjne r2,#11,q3
mov r7,#65; A=65
lcall datw1
lcall delay1
q3: cjne r2,#7,q4
mov r7,#'E'
lcall datw1
lcall delay1
q4: lcall delay
SETB p3.5
RET
; Checking for Key Press On The Third Column of 4x4 Matrix
KEY3:
clr p3.6
MOV A,p3
ANL A,#0FH
MOV r2,A
cjne r2,#14,w1
mov r7,#'3'
lcall datw1
lcall delay1
w1: cjne r2,#13,w2
mov r7,#'7'
lcall datw1
lcall delay1
w2: cjne r2,#11,w3
mov r7,#'B'
lcall datw1
lcall delay1
w3: cjne r2,#7,w4
mov r7,#'F'
lcall datw1
lcall delay1
w4: lcall delay1
SETB p3.6
RET
; Checking for Key Press on the Fourth Column of 4x4 Matrix
KEY4:
clr p3.7
MOV A,p3
ANL A,#0FH
MOV r2,A
cjne r2,#14,e1
mov r7,#'4'
lcall datw1
lcall delay1
e1: cjne r2,#13,e2
mov r7,#'8'
lcall datw1
lcall delay1
e2: cjne r2,#11,e3
mov r7,#'C'
lcall datw1
lcall delay1
e3: cjne r2,#7,e4
mov r7,#'G'
lcall datw1
lcall delay1
e4: lcall delay1
SETB p3.7
RET
disp:
mov a,#0c0H ; Setting DDRAM Address on Second Line
lcall command
; Clearing the Previous Key Pressed Information from Screen
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#0c0H ; Setting DDRAM Address on Second Line To Display “Key Pressed”
lcall command
; Display "KEY" and Pressed Information
mov a,#' '
lcall datw
mov a,#'K'
lcall datw
mov a,#'E'
lcall datw
mov a,#'Y'
lcall datw
mov a,#' '
lcall datw
RET
END
The code was written when I was learning assembly language myself and therefore the code is not
optimized, but it is easy to understand if someone is willing to check the instruction set.
People who want to optimize the code may wish to look into the DPTR Register and Addressing Modes
Theory.
A View of the Simulation
Kepad lcd 8051

More Related Content

PDF
Automatic light project
TXT
New text document
PDF
8051 experiments1
DOCX
Assembly language
PPTX
Keypad and dc motor
TXT
Comande oss
PDF
Nxll20 na ting
PDF
Https _doc-0o-c4-apps-viewer.googleusercontent
Automatic light project
New text document
8051 experiments1
Assembly language
Keypad and dc motor
Comande oss
Nxll20 na ting
Https _doc-0o-c4-apps-viewer.googleusercontent

What's hot (20)

PDF
Nxll22 role based cli
PDF
Nxll19 vrrp (virtual router redundancy protocol)
TXT
Ericsson commond list, bss+nss=oss
PDF
Eincop Netwax Lab: Access List ii
PPTX
Flip flops
PDF
Nxll26 bgp ii
PDF
Docfoc.com ericsson commands
PDF
854 f wiring
PDF
Eincop Netwax Lab: Redistribution
PDF
Nxll24 i pv6
PDF
Bolascriollas
PDF
Nxll12 zone based firewall
PDF
Nxll21 ospf filtering & summarization
PDF
Digital Counter 0-999
PPT
Cable
PDF
Nxll28 ospf iii
PDF
Eincop Netwax Lab: EIGRP ii
PPTX
Garishma ec
PDF
DMVPN Lab WorkBook
Nxll22 role based cli
Nxll19 vrrp (virtual router redundancy protocol)
Ericsson commond list, bss+nss=oss
Eincop Netwax Lab: Access List ii
Flip flops
Nxll26 bgp ii
Docfoc.com ericsson commands
854 f wiring
Eincop Netwax Lab: Redistribution
Nxll24 i pv6
Bolascriollas
Nxll12 zone based firewall
Nxll21 ospf filtering & summarization
Digital Counter 0-999
Cable
Nxll28 ospf iii
Eincop Netwax Lab: EIGRP ii
Garishma ec
DMVPN Lab WorkBook
Ad

Similar to Kepad lcd 8051 (20)

PDF
Keypad interfacing
PDF
Mic practicals
PDF
Combine the keypad and LCD codes in compliance to the following requ.pdf
PPSX
Hex keypad
PPTX
Microprocessor Week 8: Subroutine
DOCX
Basic standard calculator
PDF
Microcontroladores: El microcontrolador 8051 con LCD 16x2
DOCX
Code 8051
DOCX
Expt 5 matrix.docx
DOCX
Microcontroller (8051) general and simple alp n cprograms
PPT
Lcd & keypad
PDF
8051 instruction set
PPTX
8279keypadN.pptx
PPTX
lb instruments by using microcontroller , Rabi Moirangthem
PPTX
Microcontroller- An overview
PDF
Keypad Interfacing with 8051 Microcontroller
PDF
PPTX
micro_lecture-ch-456.pptx
PDF
3 jump, loop and call instructions
PPTX
MPMC Architecture of 8085 Microprocessor and Programming.pptx
Keypad interfacing
Mic practicals
Combine the keypad and LCD codes in compliance to the following requ.pdf
Hex keypad
Microprocessor Week 8: Subroutine
Basic standard calculator
Microcontroladores: El microcontrolador 8051 con LCD 16x2
Code 8051
Expt 5 matrix.docx
Microcontroller (8051) general and simple alp n cprograms
Lcd & keypad
8051 instruction set
8279keypadN.pptx
lb instruments by using microcontroller , Rabi Moirangthem
Microcontroller- An overview
Keypad Interfacing with 8051 Microcontroller
micro_lecture-ch-456.pptx
3 jump, loop and call instructions
MPMC Architecture of 8085 Microprocessor and Programming.pptx
Ad

More from sakru naik (8)

PDF
Power Theft Identification System Using Iot
PDF
An automated low cost IoT based Fertilizer Intimation System forsmart agricul...
PDF
Health monoring System
DOC
C 14-deee-v&vi sems
PDF
Eee r16 syllabus
DOCX
Ec lab viva
PDF
Ijst 131202
PDF
An improved dft based channel estimation
Power Theft Identification System Using Iot
An automated low cost IoT based Fertilizer Intimation System forsmart agricul...
Health monoring System
C 14-deee-v&vi sems
Eee r16 syllabus
Ec lab viva
Ijst 131202
An improved dft based channel estimation

Recently uploaded (20)

PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
737-MAX_SRG.pdf student reference guides
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPT
Total quality management ppt for engineering students
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
Abrasive, erosive and cavitation wear.pdf
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PPTX
Artificial Intelligence
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
August 2025 - Top 10 Read Articles in Network Security & Its Applications
Information Storage and Retrieval Techniques Unit III
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
737-MAX_SRG.pdf student reference guides
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Total quality management ppt for engineering students
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Safety Seminar civil to be ensured for safe working.
Abrasive, erosive and cavitation wear.pdf
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Artificial Intelligence
Management Information system : MIS-e-Business Systems.pptx
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Fundamentals of safety and accident prevention -final (1).pptx

Kepad lcd 8051

  • 1. EN equ P2.0 RS equ P2.1 RW equ P2.2 mov A,#38H ; Setting Up the LCD lcall command mov A,#0EH ; Display On lcall command mov A,#06H ; Entry Mode lcall command mov a,#82H lcall command lcall disp ; Function Disp Called mov a,#02H ; Setting DDRAM Address to Home position lcall command lcall delay1 ; Displays BOTSKOOL SHOBHIT ON FIRST LINE OF LCD mov a,#'B' lcall datw NOP mov a,#'0' lcall datw NOP mov a,#'T' lcall datw mov a,#'S' lcall datw NOP mov a,#'K' lcall datw NOP mov a,#'0' lcall datw NOP mov a,#'0' lcall datw NOP mov a,#'L' lcall datw NOP mov a,#' ' lcall datw NOP mov a,#'S' lcall datw NOP mov a,#'H' lcall datw NOP mov a,#'O' lcall datw NOP mov a,#'B' lcall datw NOP mov a,#'H' lcall datw NOP mov a,#'I'
  • 2. lcall datw NOP mov a,#'T' lcall datw MOV A,#255 ; Moving Value 255 to PORT 3 MOV P3,A ; Keypad Scan Begins sd: lcall delay1 lcall key1 lcall delay lcall key2 lcall delay lcall key3 lcall delay lcall key4 lcall delay lcall sd ; Function to Send Commands to LCD command: clr RW clr RS setB EN MOV P1,A lcall delay clr EN RET ; Function to Clear the DDRAM Content clear: mov A,#01H lcall command lcall delay mov A,#02H ; Set The DDRAM Address to Home Position lcall command lcall delay RET ; Function to Display Data on LCD Screen datw: SETB RS clr RW SETB EN MOV P1,A lcall delay clr EN RET ;Function to Display The Key Pressed datw1: lcall delay1 lcall disp lcall delay1 MOV A,R7 lcall datw RET
  • 3. ; Generating Small Delay delay: mov r0,#255 loop: DJNZ r0,loop; RET ; Generating a Bigger Delay delay1: mov r1,#255 loop1: mov r3,#120 loop2: djnz r3,loop2 djnz r1,loop1 RET ; Checking for Key Press on The First Column of 4x4 Matrix KEY1: MOV A,r5 MOV r6,A clr p3.4 MOV A,p3 ANL A,#0FH MOV r2,A cjne r2,#14,n1 MOV r7,#'1' lcall datw1 lcall delay1 n1: cjne r2,#13,n2 mov r7,#'5' lcall datw1 lcall delay1 n2: cjne r2,#11,n3 mov r7,#'9' lcall datw1 lcall delay1 n3: cjne r2,#7,n4 mov r7,#'D' lcall datw1 lcall delay1 n4: lcall delay1 SETB P3.4 RET ; Checking for Key Press on the Second Column of 4x4 Matrix KEY2: clr p3.5 MOV A,p3 ANL A,#0FH MOV r2,A cjne r2,#14,q1 mov r7,#'2' lcall datw1 lcall delay1 q1: cjne r2,#13,q2 mov r7,#'6'
  • 4. lcall datw1 lcall delay1 q2: cjne r2,#11,q3 mov r7,#65; A=65 lcall datw1 lcall delay1 q3: cjne r2,#7,q4 mov r7,#'E' lcall datw1 lcall delay1 q4: lcall delay SETB p3.5 RET ; Checking for Key Press On The Third Column of 4x4 Matrix KEY3: clr p3.6 MOV A,p3 ANL A,#0FH MOV r2,A cjne r2,#14,w1 mov r7,#'3' lcall datw1 lcall delay1 w1: cjne r2,#13,w2 mov r7,#'7' lcall datw1 lcall delay1 w2: cjne r2,#11,w3 mov r7,#'B' lcall datw1 lcall delay1 w3: cjne r2,#7,w4 mov r7,#'F' lcall datw1 lcall delay1 w4: lcall delay1 SETB p3.6 RET ; Checking for Key Press on the Fourth Column of 4x4 Matrix KEY4: clr p3.7 MOV A,p3 ANL A,#0FH MOV r2,A cjne r2,#14,e1 mov r7,#'4' lcall datw1 lcall delay1 e1: cjne r2,#13,e2 mov r7,#'8' lcall datw1 lcall delay1 e2: cjne r2,#11,e3 mov r7,#'C' lcall datw1
  • 5. lcall delay1 e3: cjne r2,#7,e4 mov r7,#'G' lcall datw1 lcall delay1 e4: lcall delay1 SETB p3.7 RET disp: mov a,#0c0H ; Setting DDRAM Address on Second Line lcall command ; Clearing the Previous Key Pressed Information from Screen mov a,#' ' lcall datw mov a,#' ' lcall datw mov a,#' ' lcall datw mov a,#' ' lcall datw mov a,#' ' lcall datw mov a,#' ' lcall datw mov a,#0c0H ; Setting DDRAM Address on Second Line To Display “Key Pressed” lcall command ; Display "KEY" and Pressed Information mov a,#' ' lcall datw mov a,#'K' lcall datw mov a,#'E' lcall datw mov a,#'Y' lcall datw mov a,#' ' lcall datw RET END The code was written when I was learning assembly language myself and therefore the code is not optimized, but it is easy to understand if someone is willing to check the instruction set. People who want to optimize the code may wish to look into the DPTR Register and Addressing Modes Theory. A View of the Simulation