SlideShare a Scribd company logo
1 of 20
Download to read offline
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

More Related Content

What's hot

L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1L8 understanding-atmega328 p-1
L8 understanding-atmega328 p-1rsamurti
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086Waleed Khan
 
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 answersAbhijith Augustine
 
Embedded systems and its ports
Embedded systems and its portsEmbedded systems and its ports
Embedded systems and its portsnitin kumar
 
Microprocess Microconroller mcq 1000+
Microprocess Microconroller mcq 1000+Microprocess Microconroller mcq 1000+
Microprocess Microconroller mcq 1000+Kumaran K
 
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_primerpvmistary
 
L15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 pL15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 prsamurti
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller featuresTech_MX
 
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 DevelopmentJonathan Ruiz de Garibay
 
Prerequriment of microcontroller
Prerequriment of microcontrollerPrerequriment of microcontroller
Prerequriment of microcontrollerKshitij Wagle
 
M.sc I-sem-8086 notes
M.sc  I-sem-8086 notesM.sc  I-sem-8086 notes
M.sc I-sem-8086 notesDr.YNM
 
Microcontrollers 80 Marks Sample Question Paper
Microcontrollers   80 Marks Sample Question PaperMicrocontrollers   80 Marks Sample Question Paper
Microcontrollers 80 Marks Sample Question Paperprathik
 
Embedded system 8051 Microcontroller
Embedded system 8051 MicrocontrollerEmbedded system 8051 Microcontroller
Embedded system 8051 Microcontrollerankitsharmaj
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingAnkur Mahajan
 
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 systemsmanishpatel_79
 

What's hot (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
 

Viewers also liked

L3 instruction-execution-steps
L3 instruction-execution-stepsL3 instruction-execution-steps
L3 instruction-execution-stepsrsamurti
 
L7 starting-to-use-mcu
L7 starting-to-use-mcuL7 starting-to-use-mcu
L7 starting-to-use-mcursamurti
 
Introduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeXIntroduction to-Tex-and-LaTeX
Introduction to-Tex-and-LaTeXrsamurti
 
Trends in-power-electronics
Trends in-power-electronicsTrends in-power-electronics
Trends in-power-electronicsrsamurti
 
Lecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power ElectronicsLecture-1 : Introduction to Power Electronics
Lecture-1 : Introduction to Power Electronicsrsamurti
 
L6 primary-memory
L6 primary-memoryL6 primary-memory
L6 primary-memoryrsamurti
 
L5 data-parallel-computers
L5 data-parallel-computersL5 data-parallel-computers
L5 data-parallel-computersrsamurti
 
Transformers
TransformersTransformers
Transformersrsamurti
 
L4 speeding-up-execution
L4 speeding-up-executionL4 speeding-up-execution
L4 speeding-up-executionrsamurti
 
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-2rsamurti
 
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 Electronicsrsamurti
 
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-4rsamurti
 
Lecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power ElectronicsLecture-2 : Applications of Power Electronics
Lecture-2 : Applications of Power Electronicsrsamurti
 
Three phase-circuits
Three phase-circuitsThree phase-circuits
Three phase-circuitsrsamurti
 
Synchronous generators
Synchronous generatorsSynchronous generators
Synchronous generatorsrsamurti
 
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-1rsamurti
 
Arduino atmega328
Arduino atmega328Arduino atmega328
Arduino atmega328Luciano FS
 
L2 types-of-computers
L2 types-of-computersL2 types-of-computers
L2 types-of-computersrsamurti
 

Viewers also liked (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
 

Similar to 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.pptlcaimi1
 
Ps2 keyboard read display system
Ps2 keyboard read display systemPs2 keyboard read display system
Ps2 keyboard read display systemWanita Long
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACnanocdac
 
1205 Ppi 8279
1205 Ppi 82791205 Ppi 8279
1205 Ppi 8279techbed
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)Mashood
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ajit kumar singh
 
AVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfacesAVR_Course_Day5 avr interfaces
AVR_Course_Day5 avr interfacesMohamed Ali
 
how to generate sms
how to generate smshow to generate sms
how to generate smssumant reddy
 
LCD Touchscreen Technology and Usage Common Touchscreen .docx
LCD Touchscreen Technology and Usage Common Touchscreen .docxLCD Touchscreen Technology and Usage Common Touchscreen .docx
LCD Touchscreen Technology and Usage Common Touchscreen .docxDIPESH30
 

Similar to L14 kb-lcd-interfacing-with-atmega328 p (20)

Mci ppt
Mci pptMci ppt
Mci ppt
 
Lcd interfacing
Lcd interfacingLcd interfacing
Lcd interfacing
 
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
 
LCD Touchscreen Technology and Usage Common Touchscreen .docx
LCD Touchscreen Technology and Usage Common Touchscreen .docxLCD Touchscreen Technology and Usage Common Touchscreen .docx
LCD Touchscreen Technology and Usage Common Touchscreen .docx
 

Recently uploaded

Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .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