SlideShare a Scribd company logo
1 of 25
LCD Interfacing
with 8051
.
Lecture Notes: 27th March 2018- 3rd April 2018
Sudhanshu Janwadkar
TA, ECED, SVNIT
Points to discuss
• Character LCD basics
• Pin description of Character LCD
• Understanding how to use character LCD
• Interfacing with 8051
Introduction
• LCD stands for Liquid Crystal Display
• Two types:
 Character LCD
 Graphics LCD
• Used to:
 Display information
• LCDs are being widely used, because they are:
 Easy to Interface
 Easy to procure
 Well documented
LCD is finding widespread use. Factors:
• The declining prices of LCD
• The ability to display numbers, characters, and
graphics
• Incorporation of a refreshing controller into the
LCD, thereby relieving the CPU of the task of
refreshing the LCD
• Ease of programming
Introduction
• A 16×2 Liquid Crystal Display can display 32
characters at a time in two rows
 16 characters in one row
• Each character in the display of size 5×7 pixel
matrix, (although this matrix differs for
different 16×2 LCD modules)
• There are 16 pins in the LCD module
Introduction
• 5 X7 pixel matrix would mean there are 5 pixels in a
row and 7 pixels in a column for display.
• Each pixel will either be black or white to represent a
character.
• The character ‘A’ would be represented as shown:
Introduction
Pin Description of LCD
• Holding LCD towards the user, Leftmost pin is
pin 1 and rightmost is pin 16
• We can divide the LCD pins into following
categories:
 Power (Pin 1,2 and 3)
 Control (Pin 4, 5 and 6)
 Data (Pin 7 through 14)
 Backlight (Pin 15 and 16)
Pin Description of LCD
Power pins
• Pin 1 is Ground. Connect it to 0v.
• Pin 2 is VDD.
 You can connect it to 5V or 3.3V (Refer to data sheet of the LCD)
• Pin 3 is contrast pin.
 A typical character LCD would have black text in foreground
and green/blue background.
 Contrast would control the difference between background and
foreground.
 This pin would be required to make the display more dark (text
dark)
 Connect Pin3 to centre point of potentiometer and adjust
contrast with help of potentiometer.
Pin Description of LCD
Control pins
• Pin 4 is RS (Register Select)
 The LCDs have two registers: Command register & data
register in a DDRAM memory.
 The control instructions like clear LCD or shift the cursor, are
stored in Command Register (also called instruction register)
 The data to be displayed such as say some character ‘a’ ‘2’ etc, it
is stored in Data register.
 If you need to send command, select the command register by
setting RS=0. If you need to send data to be displayed on LCD,
you would select data register by setting RS=1
Pin Description of LCD
Control pins
• Pin Number 5 is Read/Write pin.
 Typically, you do not read from LCD, you write to it. Hence,
most of times, you would connect it to ground.
 If you would have to read data previously stored it LCD, you
would have to make this pin 1
• Pin 6 is enable pin.
 The transitions of Enable pin are seen as clock for the registers
in LCD. Data is latched on LCD only on positive edges of the
clock (Enable pin).
 Whenever you need to write data or command to a LCD or read
from LCD, you would have to generate a high-to low pulse on
Enable pin . Seeing this transition on LCD, the LCD would
understand that it has to perform a read/write operation.
Pin Description of LCD
Data pins
• Pin Number 7 through 14 are data pins.
 You can use 4 data pins or 8 data pins, for programming your
LCD.
 If you decide to use LCD in 4-bit mode, although the
data/command that is to be send to the LCD is of 8-bits width,
you would first send lower 4 bits of data and later you would
send the upper 4-bits, i.e. lower nibble followed by the upper
one.
 Why would one go for 4-bit mode when he/she can send 8-bit
data, at a time?
 4-bit mode saves 4-pins of the microcontroller. If your
application involves multiple interfaces, it would be wiser to
save the pins of microcontroller.
 If the application has no constraints on number of pins, it would
be wiser to use 8-bit mode as LCD writing is a slow speed
operation. You do not send any high priority data to LCD. Hence,
to make your application work faster, prefer 8-bit mode in this
case.
Pin Description of LCD
Backlight pins
• Pins 15 and 16 are for controlling Backlight
 Backlight is a LED in background.
 To control the backlight, you would connect pin 15 to positive
voltage and pin 16 to negative voltage. This would light up the
LED.
 Always connect this via a resistor, as you do not want to
damage the LED.
Pin Description of LCD
Category Pin Pin Name Function
Power Pins
1 VSS Ground Pin, connected to Ground
2 VDD or Vcc Voltage Pin (+5V or 3.3 V)
Contrast Pin 3 V0 or VEE
Contrast Setting, connected to Vcc thorough a
variable resistor.
Control Pins
4 RS
Register Select Pin
RS=0 Command mode
RS=1 Data mode
5 RW
Read/ Write pin,
RW=0 Write mode,
RW=1 Read mode
6 E
Enable, a high to low pulse need to enable the
LCD
Data Pins 7-14 D0-D7
Data Pins, Stores the Data to be displayed on
LCD or the command instructions
Backlight Pins
15 LED+ or A To power the Backlight +5V
16 LED- or K Backlight Ground
Pin Description of LCD - Summary
• RS: RS is the register select pin. You need to set it to 1, if you are
sending some data to be displayed on LCD.
– And you will set it to 0 if you are sending some command
instruction like clear the screen (hex code 01).
• RW: This is Read/write pin, you will set it to 0, if you are going
to write some data on LCD.
– And set it to 1, if you are reading from LCD module.
– Generally this is set to 0, because you do not have need to
read data from LCD.
• E: This pin is used to enable the module when a high to low pulse
is given to it.
– That transition from HIGH to LOW makes the module
ENABLE.
The Three important Control pins
Pin Description of LCD
LCD Control Instructions
Hex
Code
Command to LCD Instruction Register
0F LCD ON, cursor ON
01 Clear display screen
02 Return home
04 Decrement cursor (shift cursor to left)
06 Increment cursor (shift cursor to right)
05 Shift display right
07 Shift display left
0E Display ON, cursor blinking
80 Force cursor to beginning of first line
C0 Force cursor to beginning of second line
38 2 lines and 5×7 matrix
83 Cursor line 1 position 3
3C Activate second line
08 Display OFF, cursor OFF
C1 Jump to second line, position 1
OC Display ON, cursor OFF
Note; This is not an exclusive list of LCD instructions. The user would have to refer to
datasheet of LCD he/she is using
• Commonly used LCD instructions
• Each command is a 8-bit hexadecimal data
LCD Control Instructions
Command Interpretation
30 H LCD interprets this as the user would like to set LCD in 8-bit
mode, use only 1 line (row) of LCD and the font size of 5X7 (i.e.
5 dots (pixels) in row and 7 dots (pixels) in a column)
38 H Same as above, two lines would be used
20 H LCD interprets this as the user would like to set LCD in 4-bit
mode, use only 1 line (row) of LCD and the font size of 5X7 (i.e.
5 dots (pixels) in row and 7 dots (pixels) in a column)
28 H same as above, two lines would be used.
0E H Display is on, cursor is also on and is blinking
06 H Shift the cursor right
01 H Clear the display (i.e. the contents of LCD registers will be
erased)
80H-8FH Cursor positions in first row
C0H-CFH Cursor positions in second row
Steps to write Command/Data to LCD
Steps for displaying a character or data
• RS=1; Register select should be high
• R/W=0; Read/Write pin should be low.
• E=1->0; enable pin should be given high to
low pulse
Steps to send a command to the LCD
• RS=0; Register select should be low
• R/W=1; Read/Write pin should be high
• E=1->0; enable pin should be given high to
low pulse
Interfacing 16 X 2 LCD with 8051
Writing a code• ;------------- PIN CONNECTIONS------------------------------
//Port equ P0 ;data port to connect LCD
RS equ P2.2 ;RS pin connection
RW equ P2.3 ;RW pin connection
EN equ P2.4 ;EN pin connection
; P0 is connected to data pins of LCD
ACALL init ; Subroutine for initialising the LCD
;------------------------------------------------------------
MOV A, #‘H' ; Display ‘Hi‘ in first line of LCD
ACALL lcd_data
MOV A, #’i'
ACALL lcd_data
;------------------------------------------------------------
MOV A, #0c0H ;switch to 2nd line of LCD
ACALL lcd_cmd
MOV A, #‘P' ; Display ‘Pie'
ACALL lcd_data
MOV A, #‘i'
ACALL lcd_data
MOV A, #‘e'
ACALL lcd_data
HERE: SJMP HERE ; Infinite loop to keep displaying Hi, Pie
;--------LCD INITIALISATION------------------
init:
MOV A, #38H ; 16X 2 display, use both rows, 8bit mode; 5X7 pixel matrix
ACALL lcd_cmd
MOV A, #0EH ; display on cursor blinking
ACALL lcd_cmd
MOV A, #01H ; clear the display
ACALL lcd_cmd
RET
;------------------DELAY SUBROUTINE-------------------
delay:
MOV R0, #10H
L2: MOV R1,#0FH
L1: DJNZ R1, L1
DJNZ R0, L2
RET
lcd_cmd:
CLR RS ;clear rs, going to send command
CLR RW ;clear rw, write LCD operation
MOV P0,A ;put content of A to port
SETB EN ;make EN high
ACALL DELAY ;call a short delay routine
CLR EN ;clear EN
ACALL DELAY ; short delay
RET ;return
lcd_data:
SETB RS ;clear rs, going to send command
CLR RW ;clear rw, write LCD operation
MOV P0,A ;put content of A to port
SETB EN ;make EN high
ACALL DELAY ;call a short delay routine
CLR EN ;clear EN
ACALL DELAY ; short delay
RET ;return
END
1. The LCD register accepts the ASCII value. Send the
ASCII value of data to be displayed.
2. If required, include a Binary to ASCII subroutine
3. If 4bit mode is to be used, use masking subroutine
and split data

More Related Content

What's hot

LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERsravannunna24
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051Muthu Manickam
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerSudhanshu Janwadkar
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller featuresTech_MX
 
Seven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdfSeven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdfSrikrishna Thota
 
8051 Addressing Modes
8051 Addressing Modes8051 Addressing Modes
8051 Addressing ModesSenthil Kumar
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptxMemonaMemon1
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller Gaurav Verma
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil KawareProf. Swapnil V. Kaware
 
DAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdfDAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdfSrikrishna Thota
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples Dr.YNM
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051hello_priti
 
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER   INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER SIRILsam
 

What's hot (20)

Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
TMS320C5x
TMS320C5xTMS320C5x
TMS320C5x
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
 
Adc interfacing
Adc interfacingAdc interfacing
Adc interfacing
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
 
Seven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdfSeven segment interfacing with 8051.pdf
Seven segment interfacing with 8051.pdf
 
8051 memory
8051 memory8051 memory
8051 memory
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
8051 Addressing Modes
8051 Addressing Modes8051 Addressing Modes
8051 Addressing Modes
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptx
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
 
DAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdfDAC Interfacing with 8051.pdf
DAC Interfacing with 8051.pdf
 
Interrupts in 8051
Interrupts in 8051Interrupts in 8051
Interrupts in 8051
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER   INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 

Similar to LCD Interacing with 8051

Similar to LCD Interacing with 8051 (20)

Lcd interfacing
Lcd interfacingLcd interfacing
Lcd interfacing
 
Moving message display
Moving message displayMoving message display
Moving message display
 
Lcd & keypad
Lcd & keypadLcd & keypad
Lcd & keypad
 
08_lcd.pdf
08_lcd.pdf08_lcd.pdf
08_lcd.pdf
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
 
Micro Controller 8051 of Speedo Meter using KEIL Code
Micro Controller 8051 of Speedo Meter using KEIL CodeMicro Controller 8051 of Speedo Meter using KEIL Code
Micro Controller 8051 of Speedo Meter using KEIL Code
 
LCD WITH 8051.docx
LCD WITH 8051.docxLCD WITH 8051.docx
LCD WITH 8051.docx
 
Lcd interfacing with microprocessor 8051
Lcd interfacing with microprocessor 8051Lcd interfacing with microprocessor 8051
Lcd interfacing with microprocessor 8051
 
Hd44780a00 dtasheet
Hd44780a00 dtasheetHd44780a00 dtasheet
Hd44780a00 dtasheet
 
Lecture mp 7(interface)
Lecture mp 7(interface)Lecture mp 7(interface)
Lecture mp 7(interface)
 
Arduino based applications part 2
Arduino based applications part 2Arduino based applications part 2
Arduino based applications part 2
 
Lcd tutorial
Lcd tutorialLcd tutorial
Lcd tutorial
 
An application of 8085 register interfacing with LCD
An application  of 8085 register interfacing with LCDAn application  of 8085 register interfacing with LCD
An application of 8085 register interfacing with LCD
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
 
Alp lcd
Alp lcdAlp lcd
Alp lcd
 
Interfacing with LCD
Interfacing with LCDInterfacing with LCD
Interfacing with LCD
 
LCD (2).pptx
LCD (2).pptxLCD (2).pptx
LCD (2).pptx
 
Lcd interface with atmega32 avr best.ppt
Lcd interface with atmega32 avr best.pptLcd interface with atmega32 avr best.ppt
Lcd interface with atmega32 avr best.ppt
 
report cs
report csreport cs
report cs
 
Lcd
LcdLcd
Lcd
 

More from Sudhanshu Janwadkar

ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)Sudhanshu Janwadkar
 
Fpga architectures and applications
Fpga architectures and applicationsFpga architectures and applications
Fpga architectures and applicationsSudhanshu Janwadkar
 
Introduction to 8051 Timer/Counter
Introduction to 8051 Timer/CounterIntroduction to 8051 Timer/Counter
Introduction to 8051 Timer/CounterSudhanshu Janwadkar
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerSudhanshu Janwadkar
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded SystemsSudhanshu Janwadkar
 
Interconnects in Reconfigurable Architectures
Interconnects in Reconfigurable ArchitecturesInterconnects in Reconfigurable Architectures
Interconnects in Reconfigurable ArchitecturesSudhanshu Janwadkar
 
Design and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemDesign and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemSudhanshu Janwadkar
 
Embedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual ReviewEmbedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual ReviewSudhanshu Janwadkar
 
Silicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) TechnologySilicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) TechnologySudhanshu Janwadkar
 

More from Sudhanshu Janwadkar (20)

DSP Processors versus ASICs
DSP Processors versus ASICsDSP Processors versus ASICs
DSP Processors versus ASICs
 
ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)ASIC design Flow (Digital Design)
ASIC design Flow (Digital Design)
 
Fpga architectures and applications
Fpga architectures and applicationsFpga architectures and applications
Fpga architectures and applications
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Introduction to 8051 Timer/Counter
Introduction to 8051 Timer/CounterIntroduction to 8051 Timer/Counter
Introduction to 8051 Timer/Counter
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in C
 
Hardware View of Intel 8051
Hardware View of Intel 8051Hardware View of Intel 8051
Hardware View of Intel 8051
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 Microcontroller
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 
CMOS Logic
CMOS LogicCMOS Logic
CMOS Logic
 
Interconnects in Reconfigurable Architectures
Interconnects in Reconfigurable ArchitecturesInterconnects in Reconfigurable Architectures
Interconnects in Reconfigurable Architectures
 
Introduction to FPGAs
Introduction to FPGAsIntroduction to FPGAs
Introduction to FPGAs
 
Design and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking SystemDesign and Implementation of a GPS based Personal Tracking System
Design and Implementation of a GPS based Personal Tracking System
 
Embedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual ReviewEmbedded Logic Flip-Flops: A Conceptual Review
Embedded Logic Flip-Flops: A Conceptual Review
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
 
Memory and Processor Testing
Memory and Processor TestingMemory and Processor Testing
Memory and Processor Testing
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
 
Silicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) TechnologySilicon on Insulator (SOI) Technology
Silicon on Insulator (SOI) Technology
 
VHDL Behavioral Description
VHDL Behavioral DescriptionVHDL Behavioral Description
VHDL Behavioral Description
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 

LCD Interacing with 8051

  • 1. LCD Interfacing with 8051 . Lecture Notes: 27th March 2018- 3rd April 2018 Sudhanshu Janwadkar TA, ECED, SVNIT
  • 2. Points to discuss • Character LCD basics • Pin description of Character LCD • Understanding how to use character LCD • Interfacing with 8051
  • 3. Introduction • LCD stands for Liquid Crystal Display • Two types:  Character LCD  Graphics LCD • Used to:  Display information • LCDs are being widely used, because they are:  Easy to Interface  Easy to procure  Well documented
  • 4. LCD is finding widespread use. Factors: • The declining prices of LCD • The ability to display numbers, characters, and graphics • Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing the LCD • Ease of programming Introduction
  • 5. • A 16×2 Liquid Crystal Display can display 32 characters at a time in two rows  16 characters in one row • Each character in the display of size 5×7 pixel matrix, (although this matrix differs for different 16×2 LCD modules) • There are 16 pins in the LCD module Introduction
  • 6.
  • 7. • 5 X7 pixel matrix would mean there are 5 pixels in a row and 7 pixels in a column for display. • Each pixel will either be black or white to represent a character. • The character ‘A’ would be represented as shown: Introduction
  • 8.
  • 10. • Holding LCD towards the user, Leftmost pin is pin 1 and rightmost is pin 16 • We can divide the LCD pins into following categories:  Power (Pin 1,2 and 3)  Control (Pin 4, 5 and 6)  Data (Pin 7 through 14)  Backlight (Pin 15 and 16) Pin Description of LCD
  • 11. Power pins • Pin 1 is Ground. Connect it to 0v. • Pin 2 is VDD.  You can connect it to 5V or 3.3V (Refer to data sheet of the LCD) • Pin 3 is contrast pin.  A typical character LCD would have black text in foreground and green/blue background.  Contrast would control the difference between background and foreground.  This pin would be required to make the display more dark (text dark)  Connect Pin3 to centre point of potentiometer and adjust contrast with help of potentiometer. Pin Description of LCD
  • 12. Control pins • Pin 4 is RS (Register Select)  The LCDs have two registers: Command register & data register in a DDRAM memory.  The control instructions like clear LCD or shift the cursor, are stored in Command Register (also called instruction register)  The data to be displayed such as say some character ‘a’ ‘2’ etc, it is stored in Data register.  If you need to send command, select the command register by setting RS=0. If you need to send data to be displayed on LCD, you would select data register by setting RS=1 Pin Description of LCD
  • 13. Control pins • Pin Number 5 is Read/Write pin.  Typically, you do not read from LCD, you write to it. Hence, most of times, you would connect it to ground.  If you would have to read data previously stored it LCD, you would have to make this pin 1 • Pin 6 is enable pin.  The transitions of Enable pin are seen as clock for the registers in LCD. Data is latched on LCD only on positive edges of the clock (Enable pin).  Whenever you need to write data or command to a LCD or read from LCD, you would have to generate a high-to low pulse on Enable pin . Seeing this transition on LCD, the LCD would understand that it has to perform a read/write operation. Pin Description of LCD
  • 14. Data pins • Pin Number 7 through 14 are data pins.  You can use 4 data pins or 8 data pins, for programming your LCD.  If you decide to use LCD in 4-bit mode, although the data/command that is to be send to the LCD is of 8-bits width, you would first send lower 4 bits of data and later you would send the upper 4-bits, i.e. lower nibble followed by the upper one.  Why would one go for 4-bit mode when he/she can send 8-bit data, at a time?  4-bit mode saves 4-pins of the microcontroller. If your application involves multiple interfaces, it would be wiser to save the pins of microcontroller.  If the application has no constraints on number of pins, it would be wiser to use 8-bit mode as LCD writing is a slow speed operation. You do not send any high priority data to LCD. Hence, to make your application work faster, prefer 8-bit mode in this case. Pin Description of LCD
  • 15. Backlight pins • Pins 15 and 16 are for controlling Backlight  Backlight is a LED in background.  To control the backlight, you would connect pin 15 to positive voltage and pin 16 to negative voltage. This would light up the LED.  Always connect this via a resistor, as you do not want to damage the LED. Pin Description of LCD
  • 16. Category Pin Pin Name Function Power Pins 1 VSS Ground Pin, connected to Ground 2 VDD or Vcc Voltage Pin (+5V or 3.3 V) Contrast Pin 3 V0 or VEE Contrast Setting, connected to Vcc thorough a variable resistor. Control Pins 4 RS Register Select Pin RS=0 Command mode RS=1 Data mode 5 RW Read/ Write pin, RW=0 Write mode, RW=1 Read mode 6 E Enable, a high to low pulse need to enable the LCD Data Pins 7-14 D0-D7 Data Pins, Stores the Data to be displayed on LCD or the command instructions Backlight Pins 15 LED+ or A To power the Backlight +5V 16 LED- or K Backlight Ground Pin Description of LCD - Summary
  • 17. • RS: RS is the register select pin. You need to set it to 1, if you are sending some data to be displayed on LCD. – And you will set it to 0 if you are sending some command instruction like clear the screen (hex code 01). • RW: This is Read/write pin, you will set it to 0, if you are going to write some data on LCD. – And set it to 1, if you are reading from LCD module. – Generally this is set to 0, because you do not have need to read data from LCD. • E: This pin is used to enable the module when a high to low pulse is given to it. – That transition from HIGH to LOW makes the module ENABLE. The Three important Control pins Pin Description of LCD
  • 18. LCD Control Instructions Hex Code Command to LCD Instruction Register 0F LCD ON, cursor ON 01 Clear display screen 02 Return home 04 Decrement cursor (shift cursor to left) 06 Increment cursor (shift cursor to right) 05 Shift display right 07 Shift display left 0E Display ON, cursor blinking 80 Force cursor to beginning of first line C0 Force cursor to beginning of second line 38 2 lines and 5×7 matrix 83 Cursor line 1 position 3 3C Activate second line 08 Display OFF, cursor OFF C1 Jump to second line, position 1 OC Display ON, cursor OFF Note; This is not an exclusive list of LCD instructions. The user would have to refer to datasheet of LCD he/she is using
  • 19. • Commonly used LCD instructions • Each command is a 8-bit hexadecimal data LCD Control Instructions Command Interpretation 30 H LCD interprets this as the user would like to set LCD in 8-bit mode, use only 1 line (row) of LCD and the font size of 5X7 (i.e. 5 dots (pixels) in row and 7 dots (pixels) in a column) 38 H Same as above, two lines would be used 20 H LCD interprets this as the user would like to set LCD in 4-bit mode, use only 1 line (row) of LCD and the font size of 5X7 (i.e. 5 dots (pixels) in row and 7 dots (pixels) in a column) 28 H same as above, two lines would be used. 0E H Display is on, cursor is also on and is blinking 06 H Shift the cursor right 01 H Clear the display (i.e. the contents of LCD registers will be erased) 80H-8FH Cursor positions in first row C0H-CFH Cursor positions in second row
  • 20. Steps to write Command/Data to LCD Steps for displaying a character or data • RS=1; Register select should be high • R/W=0; Read/Write pin should be low. • E=1->0; enable pin should be given high to low pulse Steps to send a command to the LCD • RS=0; Register select should be low • R/W=1; Read/Write pin should be high • E=1->0; enable pin should be given high to low pulse
  • 21. Interfacing 16 X 2 LCD with 8051
  • 22. Writing a code• ;------------- PIN CONNECTIONS------------------------------ //Port equ P0 ;data port to connect LCD RS equ P2.2 ;RS pin connection RW equ P2.3 ;RW pin connection EN equ P2.4 ;EN pin connection ; P0 is connected to data pins of LCD ACALL init ; Subroutine for initialising the LCD ;------------------------------------------------------------ MOV A, #‘H' ; Display ‘Hi‘ in first line of LCD ACALL lcd_data MOV A, #’i' ACALL lcd_data ;------------------------------------------------------------ MOV A, #0c0H ;switch to 2nd line of LCD ACALL lcd_cmd MOV A, #‘P' ; Display ‘Pie' ACALL lcd_data MOV A, #‘i' ACALL lcd_data MOV A, #‘e' ACALL lcd_data HERE: SJMP HERE ; Infinite loop to keep displaying Hi, Pie
  • 23. ;--------LCD INITIALISATION------------------ init: MOV A, #38H ; 16X 2 display, use both rows, 8bit mode; 5X7 pixel matrix ACALL lcd_cmd MOV A, #0EH ; display on cursor blinking ACALL lcd_cmd MOV A, #01H ; clear the display ACALL lcd_cmd RET ;------------------DELAY SUBROUTINE------------------- delay: MOV R0, #10H L2: MOV R1,#0FH L1: DJNZ R1, L1 DJNZ R0, L2 RET
  • 24. lcd_cmd: CLR RS ;clear rs, going to send command CLR RW ;clear rw, write LCD operation MOV P0,A ;put content of A to port SETB EN ;make EN high ACALL DELAY ;call a short delay routine CLR EN ;clear EN ACALL DELAY ; short delay RET ;return lcd_data: SETB RS ;clear rs, going to send command CLR RW ;clear rw, write LCD operation MOV P0,A ;put content of A to port SETB EN ;make EN high ACALL DELAY ;call a short delay routine CLR EN ;clear EN ACALL DELAY ; short delay RET ;return END
  • 25. 1. The LCD register accepts the ASCII value. Send the ASCII value of data to be displayed. 2. If required, include a Binary to ASCII subroutine 3. If 4bit mode is to be used, use masking subroutine and split data