You are on page 1of 3

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

LAB NO 09

Lab Title: Interfacing of keypad and 2X 16 lcd with PIC18F452

Student Name: BILAWAL HUSSAIN BHATTI Reg. No. 190337


Submitted To: Engr. MUHAMMAD AQIB
Objective: Interfacing Keypad with PIC18F452
To make students enable of controlling devices
Displaying the number passed against the pressed key on LCD display
TASK:
Write a program that displays key pressed and then released by the
keypad.

CODE:
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
char keypadport at PORTD; int i =0;
char arr[]={'O','0','=','+','1','2','3','-','4','5','6','x','7','8','9','/'};
void main() {
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
keypad_init();
while(1) { do {
i = Keypad_key_click();
delay_ms(10);
}

while(i==0);
Lcd_Chr_Cp(arr[i-1]);
}

OUTPUT:

Page | 2
Page | 3

You might also like