Professional Documents
Culture Documents
LCD
DIVISION OF MECHATRONICS
DEPARTMENT OF PRODUCTION TECHNOLOGY
MIT CAMPUS
ANNA UNIVERSITY - CHENNAI
Overview
LCD specs.
Concepts.
Algorithm.
Programming
Initialization in atmega16.
Display strings.
Outputs:
LEDS.
LCD.
7 segment.
Inputs:
Sensors.
Switch.
Keypad.
LCD
2.
RS=0, RW=0.
2.
3.
2.
Interfacing LCD
Can be interfaced either in 8-bit mode or 4-bit
mode.
LCD_DisplayString("good morning")
LCD initialization
void LCD_Init()
{
delay_us(5000);
LCD_CmdWrite(0x38); // LCD 2lines, 5*7 matrix
LCD_CmdWrite(0x0E); // Display ON cursor ON Blinking off
LCD_CmdWrite(0x01); // Clear the LCD
LCD_CmdWrite(0x80); // Cursor to First line First Position
}
INTERFACING
KEYPAD
DIVISION OF MECHATRONICS
DEPARTMENT OF PRODUCTION TECHNOLOGY
MIT CAMPUS
ANNA UNIVERSITY - CHENNAI
If no key has
been pressed,
reading the
input port will
yield 1s for all
columns since
they are all
connected to
high (Vcc)
Task
Identify the row and column of the pressed key for each of
the following.
(a) D3 D0 = 1110 for the row, D3 D0 = 1011 for the
column
(b) D3 D0 = 1101 for the row, D3 D0 = 0111 for the
column
Algorithm
Upon finding the row that the key press belongs to,
it sets up the starting address for the look-up table
holding the scan codes (or ASCII) for that row.
Flow chart
1
Start
Read all
columns
All
keys
down
??
Ground
all rows
Wait for
debounce
Read all
columns
Read all
columns
All
keys
open
??
No
Yes
N
o
All
keys
down
??
Yes
2
2
Ground
Next row
No
All
keys
down
??
Yes
Find
which key
is pressed
Get scan code
from table
Return