SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERsravannunna24
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureDominicHendry
 
ARM Architecture Instruction Set
ARM Architecture Instruction SetARM Architecture Instruction Set
ARM Architecture Instruction SetDwight Sabio
 
Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction SetDr. Pankaj Zope
 
HEARTBEAT RATE SENSOR USING MICROCONTROLLER
HEARTBEAT RATE SENSOR USING MICROCONTROLLERHEARTBEAT RATE SENSOR USING MICROCONTROLLER
HEARTBEAT RATE SENSOR USING MICROCONTROLLERRinku Meena
 
TTL Driving CMOS - Digital Electronic Presentation ALA 2018
TTL Driving CMOS - Digital Electronic Presentation ALA 2018TTL Driving CMOS - Digital Electronic Presentation ALA 2018
TTL Driving CMOS - Digital Electronic Presentation ALA 2018Mr. RahüL YøGi
 
Programmable array logic
Programmable array logicProgrammable array logic
Programmable array logicGaditek
 
Chapter 5 introduction to VHDL
Chapter 5 introduction to VHDLChapter 5 introduction to VHDL
Chapter 5 introduction to VHDLSSE_AndyLi
 
Difference Between CISC RISC, Harward & Von-neuman
Difference Between CISC RISC, Harward & Von-neumanDifference Between CISC RISC, Harward & Von-neuman
Difference Between CISC RISC, Harward & Von-neumanKailas Kharse
 
Basics of PLC
Basics of PLCBasics of PLC
Basics of PLCmohit oza
 
Divide by N clock
Divide by N clockDivide by N clock
Divide by N clockMantra VLSI
 

Was ist angesagt? (20)

LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
Ccp
CcpCcp
Ccp
 
Arduino Projects
Arduino ProjectsArduino Projects
Arduino Projects
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
ARM
ARMARM
ARM
 
Interrupts in pic
Interrupts in picInterrupts in pic
Interrupts in pic
 
8255 ppi
8255 ppi8255 ppi
8255 ppi
 
ARM Architecture Instruction Set
ARM Architecture Instruction SetARM Architecture Instruction Set
ARM Architecture Instruction Set
 
Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction Set
 
LCD interfacing
LCD interfacingLCD interfacing
LCD interfacing
 
VLSI VHDL
VLSI VHDLVLSI VHDL
VLSI VHDL
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
HEARTBEAT RATE SENSOR USING MICROCONTROLLER
HEARTBEAT RATE SENSOR USING MICROCONTROLLERHEARTBEAT RATE SENSOR USING MICROCONTROLLER
HEARTBEAT RATE SENSOR USING MICROCONTROLLER
 
TTL Driving CMOS - Digital Electronic Presentation ALA 2018
TTL Driving CMOS - Digital Electronic Presentation ALA 2018TTL Driving CMOS - Digital Electronic Presentation ALA 2018
TTL Driving CMOS - Digital Electronic Presentation ALA 2018
 
Interfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 MicrocontrollerInterfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 Microcontroller
 
Programmable array logic
Programmable array logicProgrammable array logic
Programmable array logic
 
Chapter 5 introduction to VHDL
Chapter 5 introduction to VHDLChapter 5 introduction to VHDL
Chapter 5 introduction to VHDL
 
Difference Between CISC RISC, Harward & Von-neuman
Difference Between CISC RISC, Harward & Von-neumanDifference Between CISC RISC, Harward & Von-neuman
Difference Between CISC RISC, Harward & Von-neuman
 
Basics of PLC
Basics of PLCBasics of PLC
Basics of PLC
 
Divide by N clock
Divide by N clockDivide by N clock
Divide by N clock
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie EC501 Embedded System LCD and Keypad Interface

Ähnlich wie 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
 

Kürzlich hochgeladen

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
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
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
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
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
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
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Kürzlich hochgeladen (20)

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
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
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
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
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
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
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

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