SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Interfacing Keyboard and LCD Displays
(Lecture-14)
R S Ananda Murthy
Associate Professor
Department of Electrical & Electronics Engineering,
Sri Jayachamarajendra College of Engineering,
Mysore 570 006
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Linear Arrangement of Keys
MCU
PB0
PB1
PB2
PB3
Keyboard is a collection of push-buttons.
Each key has an associated internal pull-up resistor
enabled.
In linear arrangement, number of input lines required is
equal to the number of keys.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Matrix Arrangement of Keys
When large number of keys are to be interfaced, linear
arrangement is not preferred since the number of input
lines required will be more.
In matrix arrangement, a key is connected between a row
and a column.
If there are R rows and C columns, then, the maximum
number of keys in the matrix could be N = R ×C and the
number of lines required for interfacing would be R +C and
not N.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Matrix Arrangement of Keys
0123
4567
89AB
CDEF
10k 10k 10k 10k
10k
10k
10k
10k
PD4PD5PD6PD7
Input Lines
PD3
PD2
PD1
PD0
OutputLines
Vcc
Only one 8-bit port is needed to interface 4×4 keyboard
matrix instead of two 8-bit ports as in linear arrangement.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Steps to Identity Depressed Key
1 Poll the keyboard for any previously pressed key to be
released.
2 Poll the keyboard for any key to be pressed.
3 When any key is pressed, wait for about 20 ms to
debounce the key.
4 Scan the keyboard to find which key is pressed to generate
the keycode.
5 Perform the operation assigned to a key.
6 Go back to Step-1.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Keyboard Interface Logic
Start
Ground all rows
Read columns
All keys
open
?
No
Yes
A
A
Read columns
Any key
down
?
No
Yes
Wait for debounce
B
B
Read columns
Any key
down
?
No
Yes
A
C
Identify Key
C
Do operation
assigned to key
D
D
In case of encoded keyboard, the keycode is generated by
hardware.
In case of un-encoded keyboard, the keycode has to be
generated by software.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Identifying the Depressed Key
Ground next row
Read columns
key on
in this row
?
No Yes Scan columns
to identify key
R S Ananda Murthy Interfacing Keyboard and LCD Displays
16×2 LCD Panel
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Advantages of LCD Panels
LCD panels are becoming cheaper.
LCD panels can display numbers, characters, and graphics
unlike LEDs which are limited to numbers and few
characters.
Since LCDs have an in-built refreshing controller the MCU
need not refresh the display as in the case of LEDs.
LCDs are easy to program since ASCII codes are used for
display by LCDs instead of 7-segment codes used for
LEDs.
LCDs consume less power.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
LCD Pin Descriptions
Pin Signal I/O Description
1 VSS – Ground
2 VCC – +5 V Supply
3 VEE – Power supply to control contrast
4 RS I
RS = 0 selects Command Register
RS = 1 selects Data Register
5 R/W I
R/W = 0 for write operation
R/W = 1 for read operation
6 E I/O High-to-low pulse latches data to LCD
7-14 D0-D7 I/O Lines for sending or reading data
LCD panel sizes are specified as C ×L where
C =Characters per line and L = No. of lines.
ASCII codes are used for display.
8-bits or 4bits data lines can be used for interfacing to the
MCU.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
LCD Connections using 8-bit Data Bus
10 k
Pot
PD0
PD7
.
.
.
.
.
.
.
Atmega328P LCD
D0
.
.
.
.
.
.
.
D7
PB0
PB1
PB2
RS R/W E
+ 5 V
Commands to initialize the LCD panel: 0x38, 0x0E, 0x01.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
LCD Connections using 4-bit Data Bus
10 k
Pot
PD4
PD7
.
.
.
.
Atmega328P LCD
D4
.
.
.
.
D7
PB0
PB1
PB2
RS R/W E
+5 V
Requires PB0, PB1, PB2 and higher nibble of Port D on
which data is sent, higher nibble first.
Initialization commands: 0x33, 0x32, 0x28, 0x0E, 0x01,
0x06
R S Ananda Murthy Interfacing Keyboard and LCD Displays
LCD Connections using Only One Port
10 k
Pot
PD4
PD7
.
.
.
.
Atmega328P LCD
D4
.
.
.
.
D7
PD0
PD1
PD2
RS R/W E
+ 5V
Requires only Port D.
Initialization commands: 0x33, 0x32, 0x28, 0x0E, 0x01,
0x06
R S Ananda Murthy Interfacing Keyboard and LCD Displays
LCD Command Codes
Hex Code Command to LCD Command Register
01 Clear display screen
02 Return home
04 Shift cursor to left by one position
06 Shift cursor to right by one position
05 Shift display right
07 Shift display left
08 Display off, cursor off
0A Display off, cursor on
0C Display on, cursor off
R S Ananda Murthy Interfacing Keyboard and LCD Displays
LCD Command Codes
Hex Code Command to LCD Command Register
0E Display on, cursor blinking
0F Display on, cursor blinking
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift the entire display to the right
80 Force cursor to the beginning of 1st line
C0 Force cursor to the beginning of 2nd line
28 2-lines and 5×7 matrix D4-D7, 4 bits
33 Go into 4-bit operating mode
32 Go into 4-bit operating mode
38 2-lines and 5×7 matrix D0-D7, 8 bits
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Steps for Sending Commands and Data to LCD
1 Initialize LCD.
2 Send any of the commands to the LCD for the required
operation.
3 Send the character to be shown to the LCD.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Initializing the LCD Panel
1 After power-on, wait for about 15 ms before sending the
initializing commands to the LCD panel.
2 For eg. to initialize the LCD for 5×7 matrix and 8-bit
operation, send the following commands to the command
register of the LCD panel: 0x38, 0x0E, and 0x01.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Sending Commands to the LCD Panel
Make pins RS = 0 and R/W = 0.
Place the command bits on the data pins.
Send a high-to-low pulse to the E pin of the panel.
Wait for about 100µs before sending the next command.
But in case of clear LCD (0x01) and Return Home (0x02)
commands wait for about 2 ms before issuing the next
command.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
Sending Data to the LCD Panel
Make pins RS = 1 and R/W = 0.
Place the data on the data lines in ASCII format. For
example, to display A, the ASCII code to be placed on the
data lines would be 0x41.
Send a high-to-low pulse to the E pin of the panel.
Wait for about 100µs before sending the next data.
R S Ananda Murthy Interfacing Keyboard and LCD Displays
License
This work is licensed under a
Creative Commons Attribution 4.0 International License.
R S Ananda Murthy Interfacing Keyboard and LCD Displays

Contenu connexe

Tendances

Microprocessors and microcontrollers short answer questions and answers
Microprocessors and microcontrollers short answer questions and answersMicroprocessors and microcontrollers short answer questions and answers
Microprocessors and microcontrollers short answer questions and answers
Abhijith Augustine
 
4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer
pvmistary
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
Tech_MX
 

Tendances (20)

L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
Microprocessors and microcontrollers short answer questions and answers
Microprocessors and microcontrollers short answer questions and answersMicroprocessors and microcontrollers short answer questions and answers
Microprocessors and microcontrollers short answer questions and answers
 
Embedded systems and its ports
Embedded systems and its portsEmbedded systems and its ports
Embedded systems and its ports
 
Microprocess Microconroller mcq 1000+
Microprocess Microconroller mcq 1000+Microprocess Microconroller mcq 1000+
Microprocess Microconroller mcq 1000+
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer
 
Assignment
AssignmentAssignment
Assignment
 
L15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 pL15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 p
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
 
viva q&a for mp lab
viva q&a for mp labviva q&a for mp lab
viva q&a for mp lab
 
Codesign-Oriented Platform for Agile Internet of Things Prototype Development
Codesign-Oriented Platform for Agile Internet of Things Prototype DevelopmentCodesign-Oriented Platform for Agile Internet of Things Prototype Development
Codesign-Oriented Platform for Agile Internet of Things Prototype Development
 
Prerequriment of microcontroller
Prerequriment of microcontrollerPrerequriment of microcontroller
Prerequriment of microcontroller
 
M.sc I-sem-8086 notes
M.sc  I-sem-8086 notesM.sc  I-sem-8086 notes
M.sc I-sem-8086 notes
 
Important questions
Important questionsImportant questions
Important questions
 
Microcontrollers 80 Marks Sample Question Paper
Microcontrollers   80 Marks Sample Question PaperMicrocontrollers   80 Marks Sample Question Paper
Microcontrollers 80 Marks Sample Question Paper
 
Embedded system 8051 Microcontroller
Embedded system 8051 MicrocontrollerEmbedded system 8051 Microcontroller
Embedded system 8051 Microcontroller
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
 
Solution manual the 8051 microcontroller based embedded systems
Solution manual the 8051 microcontroller based embedded systemsSolution manual the 8051 microcontroller based embedded systems
Solution manual the 8051 microcontroller based embedded systems
 

En vedette

En vedette (20)

L3 instruction-execution-steps
L3 instruction-execution-stepsL3 instruction-execution-steps
L3 instruction-execution-steps
 
L7 starting-to-use-mcu
L7 starting-to-use-mcuL7 starting-to-use-mcu
L7 starting-to-use-mcu
 
Introduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeXIntroduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeX
 
Trends in-power-electronics
Trends in-power-electronicsTrends in-power-electronics
Trends in-power-electronics
 
Lecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power ElectronicsLecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power Electronics
 
L6 primary-memory
L6 primary-memoryL6 primary-memory
L6 primary-memory
 
L5 data-parallel-computers
L5 data-parallel-computersL5 data-parallel-computers
L5 data-parallel-computers
 
Transformers
TransformersTransformers
Transformers
 
L4 speeding-up-execution
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-execution
 
Lecture-5 : Semiconductor Power Switching Devices-2
Lecture-5 : Semiconductor Power Switching Devices-2Lecture-5 : Semiconductor Power Switching Devices-2
Lecture-5 : Semiconductor Power Switching Devices-2
 
Lecture-3 : More Applications of Power Electronics
Lecture-3 : More Applications of Power ElectronicsLecture-3 : More Applications of Power Electronics
Lecture-3 : More Applications of Power Electronics
 
Lecture-7 : Semiconductor Power Switching Devices-4
Lecture-7 : Semiconductor Power Switching Devices-4Lecture-7 : Semiconductor Power Switching Devices-4
Lecture-7 : Semiconductor Power Switching Devices-4
 
Lecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power ElectronicsLecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power Electronics
 
Three phase-circuits
Three phase-circuitsThree phase-circuits
Three phase-circuits
 
Synchronous generators
Synchronous generatorsSynchronous generators
Synchronous generators
 
Lecture-4 : Semiconductor Power Switching Devices-1
Lecture-4 : Semiconductor Power Switching Devices-1Lecture-4 : Semiconductor Power Switching Devices-1
Lecture-4 : Semiconductor Power Switching Devices-1
 
Avr instruction set
Avr instruction setAvr instruction set
Avr instruction set
 
Arduino atmega328
Arduino atmega328Arduino atmega328
Arduino atmega328
 
Avr timers
Avr timersAvr timers
Avr timers
 
L2 types-of-computers
L2 types-of-computersL2 types-of-computers
L2 types-of-computers
 

Similaire à L14 kb-lcd-interfacing-with-atmega328 p

jbptunikompp-gdl-syahrul-23476-14-14-inter-y.ppt
jbptunikompp-gdl-syahrul-23476-14-14-inter-y.pptjbptunikompp-gdl-syahrul-23476-14-14-inter-y.ppt
jbptunikompp-gdl-syahrul-23476-14-14-inter-y.ppt
lcaimi1
 
how to generate sms
how to generate smshow to generate sms
how to generate sms
sumant reddy
 

Similaire à L14 kb-lcd-interfacing-with-atmega328 p (20)

Mci ppt
Mci pptMci ppt
Mci ppt
 
Lcd interfacing
Lcd interfacingLcd interfacing
Lcd interfacing
 
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
 
jbptunikompp-gdl-syahrul-23476-14-14-inter-y.ppt
jbptunikompp-gdl-syahrul-23476-14-14-inter-y.pptjbptunikompp-gdl-syahrul-23476-14-14-inter-y.ppt
jbptunikompp-gdl-syahrul-23476-14-14-inter-y.ppt
 
Arduino based applications part 2
Arduino based applications part 2Arduino based applications part 2
Arduino based applications part 2
 
Ps2 keyboard read display system
Ps2 keyboard read display systemPs2 keyboard read display system
Ps2 keyboard read display system
 
LCD WITH 8051.docx
LCD WITH 8051.docxLCD WITH 8051.docx
LCD WITH 8051.docx
 
Lecture mp 7(interface)
Lecture mp 7(interface)Lecture mp 7(interface)
Lecture mp 7(interface)
 
Hd44780a00 dtasheet
Hd44780a00 dtasheetHd44780a00 dtasheet
Hd44780a00 dtasheet
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
1205 Ppi 8279
1205 Ppi 82791205 Ppi 8279
1205 Ppi 8279
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
 
AVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfacesAVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfaces
 
Lcd & keypad
Lcd & keypadLcd & keypad
Lcd & keypad
 
how to generate sms
how to generate smshow to generate sms
how to generate sms
 
report cs
report csreport cs
report cs
 
Interfacing with LCD
Interfacing with LCDInterfacing with LCD
Interfacing with LCD
 

Dernier

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Dernier (20)

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 

L14 kb-lcd-interfacing-with-atmega328 p

  • 1. Interfacing Keyboard and LCD Displays (Lecture-14) R S Ananda Murthy Associate Professor Department of Electrical & Electronics Engineering, Sri Jayachamarajendra College of Engineering, Mysore 570 006 R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 2. Linear Arrangement of Keys MCU PB0 PB1 PB2 PB3 Keyboard is a collection of push-buttons. Each key has an associated internal pull-up resistor enabled. In linear arrangement, number of input lines required is equal to the number of keys. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 3. Matrix Arrangement of Keys When large number of keys are to be interfaced, linear arrangement is not preferred since the number of input lines required will be more. In matrix arrangement, a key is connected between a row and a column. If there are R rows and C columns, then, the maximum number of keys in the matrix could be N = R ×C and the number of lines required for interfacing would be R +C and not N. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 4. Matrix Arrangement of Keys 0123 4567 89AB CDEF 10k 10k 10k 10k 10k 10k 10k 10k PD4PD5PD6PD7 Input Lines PD3 PD2 PD1 PD0 OutputLines Vcc Only one 8-bit port is needed to interface 4×4 keyboard matrix instead of two 8-bit ports as in linear arrangement. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 5. Steps to Identity Depressed Key 1 Poll the keyboard for any previously pressed key to be released. 2 Poll the keyboard for any key to be pressed. 3 When any key is pressed, wait for about 20 ms to debounce the key. 4 Scan the keyboard to find which key is pressed to generate the keycode. 5 Perform the operation assigned to a key. 6 Go back to Step-1. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 6. Keyboard Interface Logic Start Ground all rows Read columns All keys open ? No Yes A A Read columns Any key down ? No Yes Wait for debounce B B Read columns Any key down ? No Yes A C Identify Key C Do operation assigned to key D D In case of encoded keyboard, the keycode is generated by hardware. In case of un-encoded keyboard, the keycode has to be generated by software. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 7. Identifying the Depressed Key Ground next row Read columns key on in this row ? No Yes Scan columns to identify key R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 8. 16×2 LCD Panel R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 9. Advantages of LCD Panels LCD panels are becoming cheaper. LCD panels can display numbers, characters, and graphics unlike LEDs which are limited to numbers and few characters. Since LCDs have an in-built refreshing controller the MCU need not refresh the display as in the case of LEDs. LCDs are easy to program since ASCII codes are used for display by LCDs instead of 7-segment codes used for LEDs. LCDs consume less power. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 10. LCD Pin Descriptions Pin Signal I/O Description 1 VSS – Ground 2 VCC – +5 V Supply 3 VEE – Power supply to control contrast 4 RS I RS = 0 selects Command Register RS = 1 selects Data Register 5 R/W I R/W = 0 for write operation R/W = 1 for read operation 6 E I/O High-to-low pulse latches data to LCD 7-14 D0-D7 I/O Lines for sending or reading data LCD panel sizes are specified as C ×L where C =Characters per line and L = No. of lines. ASCII codes are used for display. 8-bits or 4bits data lines can be used for interfacing to the MCU. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 11. LCD Connections using 8-bit Data Bus 10 k Pot PD0 PD7 . . . . . . . Atmega328P LCD D0 . . . . . . . D7 PB0 PB1 PB2 RS R/W E + 5 V Commands to initialize the LCD panel: 0x38, 0x0E, 0x01. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 12. LCD Connections using 4-bit Data Bus 10 k Pot PD4 PD7 . . . . Atmega328P LCD D4 . . . . D7 PB0 PB1 PB2 RS R/W E +5 V Requires PB0, PB1, PB2 and higher nibble of Port D on which data is sent, higher nibble first. Initialization commands: 0x33, 0x32, 0x28, 0x0E, 0x01, 0x06 R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 13. LCD Connections using Only One Port 10 k Pot PD4 PD7 . . . . Atmega328P LCD D4 . . . . D7 PD0 PD1 PD2 RS R/W E + 5V Requires only Port D. Initialization commands: 0x33, 0x32, 0x28, 0x0E, 0x01, 0x06 R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 14. LCD Command Codes Hex Code Command to LCD Command Register 01 Clear display screen 02 Return home 04 Shift cursor to left by one position 06 Shift cursor to right by one position 05 Shift display right 07 Shift display left 08 Display off, cursor off 0A Display off, cursor on 0C Display on, cursor off R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 15. LCD Command Codes Hex Code Command to LCD Command Register 0E Display on, cursor blinking 0F Display on, cursor blinking 10 Shift cursor position to left 14 Shift cursor position to right 18 Shift the entire display to the left 1C Shift the entire display to the right 80 Force cursor to the beginning of 1st line C0 Force cursor to the beginning of 2nd line 28 2-lines and 5×7 matrix D4-D7, 4 bits 33 Go into 4-bit operating mode 32 Go into 4-bit operating mode 38 2-lines and 5×7 matrix D0-D7, 8 bits R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 16. Steps for Sending Commands and Data to LCD 1 Initialize LCD. 2 Send any of the commands to the LCD for the required operation. 3 Send the character to be shown to the LCD. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 17. Initializing the LCD Panel 1 After power-on, wait for about 15 ms before sending the initializing commands to the LCD panel. 2 For eg. to initialize the LCD for 5×7 matrix and 8-bit operation, send the following commands to the command register of the LCD panel: 0x38, 0x0E, and 0x01. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 18. Sending Commands to the LCD Panel Make pins RS = 0 and R/W = 0. Place the command bits on the data pins. Send a high-to-low pulse to the E pin of the panel. Wait for about 100µs before sending the next command. But in case of clear LCD (0x01) and Return Home (0x02) commands wait for about 2 ms before issuing the next command. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 19. Sending Data to the LCD Panel Make pins RS = 1 and R/W = 0. Place the data on the data lines in ASCII format. For example, to display A, the ASCII code to be placed on the data lines would be 0x41. Send a high-to-low pulse to the E pin of the panel. Wait for about 100µs before sending the next data. R S Ananda Murthy Interfacing Keyboard and LCD Displays
  • 20. License This work is licensed under a Creative Commons Attribution 4.0 International License. R S Ananda Murthy Interfacing Keyboard and LCD Displays