SlideShare a Scribd company logo
1 of 19
EC501-EMBEDDED SYSTEM 
APPLICATION 
LCD & 
KEYPAD 
Izwanizam bin Yahaya / JKE/ PTSB
OBJECTIVES 
1. Describe LCDs mode of operation and to interface 
with PIC Microcontroller 
2. Construct a program code to send commands and 
data to LCD 
3. Describe 4 x 4 Matrix keypad basic of operation 
4. Illustrate key press detection and key identification 
mechanism 
5. Apply program code to Write keypad and display to 
LCD in C programming
LCD Interfacing 
• LCD stands for Liquid Crystal Display 
??????????????????? 
• Most LCDs with one controller have 14 pins or 16 pins 
• Two extra pins are for back-light LED connections while LCDs with 
two controllers have two more pins to enable the additional controller 
• Most commonly used character based LCDs are based on 
Hitachi’s HD44780 controller or other which are compatible with 
HD44580.
LCD Control lines 
The three control lines are 
referred to as EN, RS, and RW. 
The EN line is called “Enable.” 
-to tell the LCD that you are 
sending in data. 
-To send data to the LCD, your 
program should make sure this line 
is low (0) and then set the other two 
control lines and/or put data on the 
data bus. 
-When the other lines are 
completely ready, bring EN high (1) 
and wait for the minimum amount of 
time required by the LCD datasheet 
and end by bringing it low (0) 
again.
RS & RW & DATA BUS ??? 
The RS line is the “Register Select” line. When RS is low (0), the data is to 
be treated as a command or special instruction (such as clear screen, 
position cursor, etc.). When RS is high (1), the data being sent is text data 
which sould be displayed on the screen. For example, to display the letter 
“T” on the screen you would set RS high. 
The RW line is the “Read/Write” control line. When RW is low (0), the 
information on the data bus is being written to the LCD. When RW is high 
(1), the program is effectively querying (or reading) the LCD. Only one 
instruction (“Get LCD status”) is a read command. All others are write 
commands–so RW will almost always be low. 
The data bus consists of 4 or 8 lines (depending on the mode of 
operation selected by the user). In the case of an 8-bit data bus, the 
lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and 
DB7.
LCD Modes Operation 
For 4 bits data 
For 8 bits data
LCD hardware connection to PIC microcontroller 
RB5, RB6 and RB7 of PIC are used for the control signals while 
PORTD of the microcontroller is the data bus.
<=PIC1 
6 
#include <p18f45k22.h> 
#define FREQ 4 //MHz 
#define MSLOOP ((FREQ*16)+(FREQ/4)) 
// PORTB & PORTD 
#define LCD_DATA LATD //-> RD0..RD7 
#define LCD_EN LATBbits.LATB7 //-> LCD EN 
#define LCD_RS LATBbits.LATB5 //-> LCD RS 
#define LCD_RW LATBbits.LATB6 //-> LCD R/W 
<= PIC18 
Programming Code
Find the control lines LCD to PIC pin && 44 bbiitt ddaattaa bbuuss ppiinn?????? 
RS = _____________ D4 = ___________ 
RW = ________________ D5 = ____________ 
E = ________________ D6 = ____________ 
D7 = ____________ 
TASK 1 
Mode operation ?
TASK 2 
# Define? 
Write the ddeeffiinnee pprrooggrraammmmiinngg ccooddee ?????? 
#define LCD_DATA LATB //-> RB4..RB7 
#define LCD_EN LATBbits.LATB3 //-> LCD EN 
#define LCD_RS LATBbits.LATB2 //-> LCD RS 
#define LCD_RW LATBbits.LATB1 //-> LCD R/W
Keypad Interfacing 
• Matrix keypads are very useful when designing certain 
system which needs user input. 
• By arranging push button switches in rows and columns. 
• To scan which button is pressed, we need to scan it column by column 
and row by row. 
• Make rows as input and columns as output. 
• For keypad wiring , need to pull up or pull down to avoid floating. 
Pull-up R 
Active HIGH 
Pull-down R 
Active LOW
ROWS & COLUMNS ?? 
Pull-up 
Resistor 
COL(OUTPUT) = HIGH
Key Press Detection ??
case 1 kp = 49 ' 1 ‘ Uncomment this block for 
keypad4x4 
case 2 kp = 50 ' 2 
case 3 kp = 51 ' 3 
case 4 kp = 65 ' A 
case 5 kp = 52 ' 4 
case 6 kp = 53 ' 5 
case 7 kp = 54 ' 6 
case 8 kp = 66 ' B 
case 9 kp = 55 ' 7 
case 10 kp = 56 ' 8 
case 11 kp = 57 ' 9 
case 12 kp = 67 ' C 
case 13 kp = 42 ' * 
case 14 kp = 48 ' 0 
case 15 kp = 35 ' # 
case 16 kp = 68 ' D 
ASCII code
Keypad Define code 
#include <p18f45k22.h> 
//IO define 
#define ROW1 PORTAbits.RA5 //Keypad Row (input) 
#define ROW2 PORTEbits.RE0 
#define ROW3 PORTEbits.RE1 
#define ROW4 PORTEbits.RE2 
#define COL1 LATAbits.LATA1 //Keypad Col (output) 
#define COL2 LATAbits.LATA2 
#define COL3 LATAbits.LATA3 
#define COL4 LATAbits.LATA4 
#define LED0 LATBbits.LATB0 
#define LED1 LATBbits.LATB1 
#define LED2 LATBbits.LATB2 
#define LED3 LATBbits.LATB3
//MAIN PROGRAM 
void main(void) 
{ 
unsigned char Key,Run; //local variables 
OSCCON=0x52; //PIC18F45K22 : INTOSC 4MHz 
Initialize(); 
Key=0; // activate key by col 
//Main Loop 
while(1){ 
COL2=0; 
if (!Key)Key=1; 
{ if (!COL2){ 
if(!ROW1) LED0=1; else LED=0; 
if(!ROW2) LED1=1; else LED1=0; 
if(!ROW3) LED2=1; else LED2=0; 
if(!ROW4) LED3=1; else LED3=0; 
COL2=1; 
Nop(); 
Nop(); 
COL3=0; 
//Key=1; 
} 
if (!COL3){ 
if(!ROW1) LED3=1; else LED3=0; 
if(!ROW2) LED2=1; else LED2=0; 
if(!ROW3) LED1=1; else LED1=0; 
if(!ROW4) LED0=1; else LED=0; 
} 
}} 
} 
Pull-up R 
COLLUMN2 is ACTIVE ! 
Can press any ROW… 
COLLUMN3 is ACTIVE !
//Init Micro-controller 
void Initialize(void) 
{ 
//Init IO 
ANSELA=0; //ANSEL=0; ANSELH=0 => PIC887 
ANSELB=0; 
ANSELC=0; 
ANSELD=0; 
ANSELE=0; 
PORTB=0; 
TRISA=0b11100001; //RA1-RA4 o/p RA5 i/p 
TRISB=0b11110000; //PORTB I/O Direction (0:Output 1:Input) 
LATA=0b00011110; //RA1-RA4 set Hi 
} 
COLUMNS output pin 
LED output pin
LCD & Keypad Microcontroller 
Circuit
Question ?? 
1.Give the combination ROW & COL for: 
i. Keypad number 5 ROW2 & COL2 
ii. Keypad # ROW4 & COL3 
iii. Keypad B ROW2 & COL4 
2. State the ASCII key for this arrangement 
keypad press: 
i. Row2 & Col3 case ASCII code= 54 // => 6 
ii. Row3 & Col4 case ASCII code= 67 // => C

More Related Content

What's hot

8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
INTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSORINTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSORGurudev joshi
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...manishpatel_79
 
8085 interfacing with memory chips
8085 interfacing with memory chips8085 interfacing with memory chips
8085 interfacing with memory chipsSrikrishna Thota
 
8257 DMA Controller
8257 DMA Controller8257 DMA Controller
8257 DMA ControllerShivamSood22
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...NimeshSingh27
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarGauravRaikar3
 
VLSI subsystem design processes and illustration
VLSI subsystem design processes and illustrationVLSI subsystem design processes and illustration
VLSI subsystem design processes and illustrationVishal kakade
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontrollerSiva Kumar
 
Introduction to ARM LPC2148
Introduction to ARM LPC2148Introduction to ARM LPC2148
Introduction to ARM LPC2148Veera Kumar
 
ARM Exception and interrupts
ARM Exception and interrupts ARM Exception and interrupts
ARM Exception and interrupts NishmaNJ
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.pptDr.YNM
 
Memory Segmentation of 8086
Memory Segmentation of 8086Memory Segmentation of 8086
Memory Segmentation of 8086Nikhil Kumar
 
8096 microcontrollers notes
8096 microcontrollers notes8096 microcontrollers notes
8096 microcontrollers notesDr.YNM
 

What's hot (20)

8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
INTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSORINTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSOR
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...
 
8085 interfacing with memory chips
8085 interfacing with memory chips8085 interfacing with memory chips
8085 interfacing with memory chips
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
8257 DMA Controller
8257 DMA Controller8257 DMA Controller
8257 DMA Controller
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikar
 
VLSI subsystem design processes and illustration
VLSI subsystem design processes and illustrationVLSI subsystem design processes and illustration
VLSI subsystem design processes and illustration
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
 
8051 ch9-950217
8051 ch9-9502178051 ch9-950217
8051 ch9-950217
 
Introduction to ARM LPC2148
Introduction to ARM LPC2148Introduction to ARM LPC2148
Introduction to ARM LPC2148
 
ARM Exception and interrupts
ARM Exception and interrupts ARM Exception and interrupts
ARM Exception and interrupts
 
Misra c
Misra cMisra c
Misra c
 
Unit 1
Unit 1Unit 1
Unit 1
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
 
Memory Segmentation of 8086
Memory Segmentation of 8086Memory Segmentation of 8086
Memory Segmentation of 8086
 
8096 microcontrollers notes
8096 microcontrollers notes8096 microcontrollers notes
8096 microcontrollers notes
 

Viewers also liked

Smart digital door locking system
Smart digital door locking systemSmart digital door locking system
Smart digital door locking systemVISHAL NAGAR
 
06 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.201606 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.2016Mohamed Fawzy
 
Interfacing keypad
Interfacing keypadInterfacing keypad
Interfacing keypadPRADEEP
 
7 segment interface with avr microcontroller
7 segment interface with avr microcontroller7 segment interface with avr microcontroller
7 segment interface with avr microcontrollerKushagra Ganeriwal
 
ARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMVishal GARG
 
Embedded System Practical manual (1)
Embedded System Practical manual (1)Embedded System Practical manual (1)
Embedded System Practical manual (1)Niraj Bharambe
 
A.F. Ismail (presentation)
A.F. Ismail (presentation)A.F. Ismail (presentation)
A.F. Ismail (presentation)Elektro_UMBO
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersMohamed Tarek
 
T.H. (presentation)
T.H. (presentation)T.H. (presentation)
T.H. (presentation)ElektroUMBO
 
Embedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontrollerEmbedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontrollerArun Kumar
 
Embedded system development-Arduino UNO
Embedded system development-Arduino UNOEmbedded system development-Arduino UNO
Embedded system development-Arduino UNOayush sultania
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsEdgefxkits & Solutions
 
Microcontroller
MicrocontrollerMicrocontroller
MicrocontrollerSpitiq
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVRDaksh Raj Chopra
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduinoSantosh Verma
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded SystemsMohamed Tarek
 
Embedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerEmbedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerAmandeep Alag
 

Viewers also liked (20)

Smart digital door locking system
Smart digital door locking systemSmart digital door locking system
Smart digital door locking system
 
06 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.201606 Interfacing Keypad 4x4.2016
06 Interfacing Keypad 4x4.2016
 
Interfacing keypad
Interfacing keypadInterfacing keypad
Interfacing keypad
 
Final Report
Final ReportFinal Report
Final Report
 
7 segment interface with avr microcontroller
7 segment interface with avr microcontroller7 segment interface with avr microcontroller
7 segment interface with avr microcontroller
 
ARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEM
 
Embedded System Practical manual (1)
Embedded System Practical manual (1)Embedded System Practical manual (1)
Embedded System Practical manual (1)
 
A.F. Ismail (presentation)
A.F. Ismail (presentation)A.F. Ismail (presentation)
A.F. Ismail (presentation)
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr Microcontrollers
 
T.H. (presentation)
T.H. (presentation)T.H. (presentation)
T.H. (presentation)
 
Embedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontrollerEmbedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontroller
 
Embedded system development-Arduino UNO
Embedded system development-Arduino UNOEmbedded system development-Arduino UNO
Embedded system development-Arduino UNO
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applications
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
Interfacing using ِAtmega16/32
Interfacing using ِAtmega16/32 Interfacing using ِAtmega16/32
Interfacing using ِAtmega16/32
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVR
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 
Embedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerEmbedded systems, 8051 microcontroller
Embedded systems, 8051 microcontroller
 
Question bank
Question bankQuestion bank
Question bank
 

Similar to EC501 Embedded System LCD and Keypad Interface

Similar to EC501 Embedded System LCD and Keypad Interface (20)

131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
Moving message display
Moving message displayMoving message display
Moving message display
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 
Lcd tutorial
Lcd tutorialLcd tutorial
Lcd tutorial
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
08_lcd.pdf
08_lcd.pdf08_lcd.pdf
08_lcd.pdf
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
 
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
 
_LCD display-mbed.pdf
_LCD display-mbed.pdf_LCD display-mbed.pdf
_LCD display-mbed.pdf
 
Interfacing with LCD
Interfacing with LCDInterfacing with LCD
Interfacing with LCD
 
report cs
report csreport cs
report cs
 
Assignment
AssignmentAssignment
Assignment
 
Alp lcd
Alp lcdAlp lcd
Alp lcd
 
The functional design scheme of the dedicated keyboard chip kb core based on ...
The functional design scheme of the dedicated keyboard chip kb core based on ...The functional design scheme of the dedicated keyboard chip kb core based on ...
The functional design scheme of the dedicated keyboard chip kb core based on ...
 
Automatic room light controller with visible counter
Automatic room light controller with visible counterAutomatic room light controller with visible counter
Automatic room light controller with visible counter
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
arduinoedit.pptx
arduinoedit.pptxarduinoedit.pptx
arduinoedit.pptx
 

Recently uploaded

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 

Recently uploaded (20)

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
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 

EC501 Embedded System LCD and Keypad Interface

  • 1. EC501-EMBEDDED SYSTEM APPLICATION LCD & KEYPAD Izwanizam bin Yahaya / JKE/ PTSB
  • 2. OBJECTIVES 1. Describe LCDs mode of operation and to interface with PIC Microcontroller 2. Construct a program code to send commands and data to LCD 3. Describe 4 x 4 Matrix keypad basic of operation 4. Illustrate key press detection and key identification mechanism 5. Apply program code to Write keypad and display to LCD in C programming
  • 3. LCD Interfacing • LCD stands for Liquid Crystal Display ??????????????????? • Most LCDs with one controller have 14 pins or 16 pins • Two extra pins are for back-light LED connections while LCDs with two controllers have two more pins to enable the additional controller • Most commonly used character based LCDs are based on Hitachi’s HD44780 controller or other which are compatible with HD44580.
  • 4. LCD Control lines The three control lines are referred to as EN, RS, and RW. The EN line is called “Enable.” -to tell the LCD that you are sending in data. -To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. -When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet and end by bringing it low (0) again.
  • 5. RS & RW & DATA BUS ??? The RS line is the “Register Select” line. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which sould be displayed on the screen. For example, to display the letter “T” on the screen you would set RS high. The RW line is the “Read/Write” control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction (“Get LCD status”) is a read command. All others are write commands–so RW will almost always be low. The data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
  • 6. LCD Modes Operation For 4 bits data For 8 bits data
  • 7. LCD hardware connection to PIC microcontroller RB5, RB6 and RB7 of PIC are used for the control signals while PORTD of the microcontroller is the data bus.
  • 8. <=PIC1 6 #include <p18f45k22.h> #define FREQ 4 //MHz #define MSLOOP ((FREQ*16)+(FREQ/4)) // PORTB & PORTD #define LCD_DATA LATD //-> RD0..RD7 #define LCD_EN LATBbits.LATB7 //-> LCD EN #define LCD_RS LATBbits.LATB5 //-> LCD RS #define LCD_RW LATBbits.LATB6 //-> LCD R/W <= PIC18 Programming Code
  • 9. Find the control lines LCD to PIC pin && 44 bbiitt ddaattaa bbuuss ppiinn?????? RS = _____________ D4 = ___________ RW = ________________ D5 = ____________ E = ________________ D6 = ____________ D7 = ____________ TASK 1 Mode operation ?
  • 10. TASK 2 # Define? Write the ddeeffiinnee pprrooggrraammmmiinngg ccooddee ?????? #define LCD_DATA LATB //-> RB4..RB7 #define LCD_EN LATBbits.LATB3 //-> LCD EN #define LCD_RS LATBbits.LATB2 //-> LCD RS #define LCD_RW LATBbits.LATB1 //-> LCD R/W
  • 11. Keypad Interfacing • Matrix keypads are very useful when designing certain system which needs user input. • By arranging push button switches in rows and columns. • To scan which button is pressed, we need to scan it column by column and row by row. • Make rows as input and columns as output. • For keypad wiring , need to pull up or pull down to avoid floating. Pull-up R Active HIGH Pull-down R Active LOW
  • 12. ROWS & COLUMNS ?? Pull-up Resistor COL(OUTPUT) = HIGH
  • 14. case 1 kp = 49 ' 1 ‘ Uncomment this block for keypad4x4 case 2 kp = 50 ' 2 case 3 kp = 51 ' 3 case 4 kp = 65 ' A case 5 kp = 52 ' 4 case 6 kp = 53 ' 5 case 7 kp = 54 ' 6 case 8 kp = 66 ' B case 9 kp = 55 ' 7 case 10 kp = 56 ' 8 case 11 kp = 57 ' 9 case 12 kp = 67 ' C case 13 kp = 42 ' * case 14 kp = 48 ' 0 case 15 kp = 35 ' # case 16 kp = 68 ' D ASCII code
  • 15. Keypad Define code #include <p18f45k22.h> //IO define #define ROW1 PORTAbits.RA5 //Keypad Row (input) #define ROW2 PORTEbits.RE0 #define ROW3 PORTEbits.RE1 #define ROW4 PORTEbits.RE2 #define COL1 LATAbits.LATA1 //Keypad Col (output) #define COL2 LATAbits.LATA2 #define COL3 LATAbits.LATA3 #define COL4 LATAbits.LATA4 #define LED0 LATBbits.LATB0 #define LED1 LATBbits.LATB1 #define LED2 LATBbits.LATB2 #define LED3 LATBbits.LATB3
  • 16. //MAIN PROGRAM void main(void) { unsigned char Key,Run; //local variables OSCCON=0x52; //PIC18F45K22 : INTOSC 4MHz Initialize(); Key=0; // activate key by col //Main Loop while(1){ COL2=0; if (!Key)Key=1; { if (!COL2){ if(!ROW1) LED0=1; else LED=0; if(!ROW2) LED1=1; else LED1=0; if(!ROW3) LED2=1; else LED2=0; if(!ROW4) LED3=1; else LED3=0; COL2=1; Nop(); Nop(); COL3=0; //Key=1; } if (!COL3){ if(!ROW1) LED3=1; else LED3=0; if(!ROW2) LED2=1; else LED2=0; if(!ROW3) LED1=1; else LED1=0; if(!ROW4) LED0=1; else LED=0; } }} } Pull-up R COLLUMN2 is ACTIVE ! Can press any ROW… COLLUMN3 is ACTIVE !
  • 17. //Init Micro-controller void Initialize(void) { //Init IO ANSELA=0; //ANSEL=0; ANSELH=0 => PIC887 ANSELB=0; ANSELC=0; ANSELD=0; ANSELE=0; PORTB=0; TRISA=0b11100001; //RA1-RA4 o/p RA5 i/p TRISB=0b11110000; //PORTB I/O Direction (0:Output 1:Input) LATA=0b00011110; //RA1-RA4 set Hi } COLUMNS output pin LED output pin
  • 18. LCD & Keypad Microcontroller Circuit
  • 19. Question ?? 1.Give the combination ROW & COL for: i. Keypad number 5 ROW2 & COL2 ii. Keypad # ROW4 & COL3 iii. Keypad B ROW2 & COL4 2. State the ASCII key for this arrangement keypad press: i. Row2 & Col3 case ASCII code= 54 // => 6 ii. Row3 & Col4 case ASCII code= 67 // => C