Microlab 9
Microlab 9
EXPERIMENT NO 9
Lab Title:
____________________________________________________________________
Student Name: ______________________________________ Reg. No:
_________________
Objective: ___________________________________________________________________
____________________________________________________________________________
LAB ASSESSMENT:
Data presentation
Experimental results
Conclusion
Objective:
Familiarizing students to interface keypad with PIC18F452 and display results on SSD
Familiarizing students to interface LCD with PIC18F452 and display data on the LCD
Familiarizing students to interface a 4x3 keypad with PIC18F452 and display results on LCD
Equipment:
Hardware:
1. PIC18F452 microcontroller
2. 4x3 Keypad
3. 16x2 LCD
4. RIMS Trainer
5. SSD
Software:
1. mikroC Pro
2. SmartPRO 5000U
3. Proteus
Introduction:
Interfacing PIC microcontroller with keypad helps in the design of various applications which control
different processes and actions by just a key press. One can design a password protected application using
keypad digits or provide users with different options represented by different digits by using keypad
interfacing.
Keypad:
A keypad is a block of buttons set with an arrangement of digits, symbols, or alphabetical letters. A
keypad is a specially designed circuitry which works on row and column selection operation. When a key
is pressed, a row is internally shorted with a column corresponding to that digit.
A 4x3 keypad has12 individual push buttons and the configuration requires 13 input pins in order to make
them work. However, with matrix arrangement, one only needs 7 microcontroller pins to scan through the
keypad.
Scanning a Keypress:
LCD:
An LCD screen is an electronic display module that uses liquid crystal to produce a visible image. The
16×2 LCD display is a very basic module which displays 16 characters per line and has 2 such lines. Each
character in this LCD is displayed in a 5×8 pixel matrix. The main benefits of using this module are that
LCDs are inexpensive and easily programmable. There are no limitations in displaying custom characters,
and even animations, etc.
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user
may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is
used, the LCD will require a total of 7 data lines. If an 8-bit data bus is used, the LCD will require a total
of 11 data lines. The three control lines are EN, RS, and RW.
The mikroC PRO for PIC provides a library for communication with Lcds (with HD44780 compliant
controllers) through the 4-bit interface. The LCD library for PIC has following important functions:
Command Description
_LCD_FIRST_ROW Move cursor to the 1st row
_LCD_SECOND_ROW Move cursor to the 2nd row
_LCD_CLEAR Clear display
_LCD_CURSOR_OFF Turn off cursor
_LCD_UNDERLINE_ON Underline cursor on
_LCD_BLINK_CURSOR_ON Blink cursor on
_LCD_MOVE_CURSOR_LEFT Move cursor left without changing display data RAM
_LCD_MOVE_CURSOR_RIGHT Move cursor right without changing display data RAM
_LCD_TURN_ON Turn LCD display on
_LCD_TURN_OFF Turn LCD display off
_LCD_SHIFT_LEFT Shift display left without changing display data RAM
_LCD_SHIFT_RIGHT Shift display right without changing display data RAM
Return cursor to home position, returns a shifted display to its
_LCD_RETURN_HOME
original position. Display data RAM is unaffected.
Lab Task 1:
Write a code in mikroC to display your name on a 16x2 LCD, surround it with Custom characters created
using MikroC tools and rotate it out of the screen. Use PIC18F452 and verify the results on Proteus and
hardware
Lab Task 2:
Write a code in MikroC to interface a 4x3 Keypad with PIC18F452 such that the number pressed on
keypad is displayed on LCD. Verify the results on Proteus and hardware.
Conclusion: