Lcds
Lcds
Lcds
LCD Display
+ 5V
Potentiometer
16 pins total
Pinout of LCD
Enable Pin
Backlighting control
LCD Interfacing
5 x 7 matrix of
LCD elements for
each character
LCDs & Interfacing
Addressing with 4 bits vs 8 bits
This LCD has two interfaces
o One 8-bit interface or 2 4-bit interfaces
o We will be using the 4-bit interface
This is a timing
diagram.
Sending LCD Commands
This is a timing
diagram.
Increasing Time
Sending LCD Commands
This describes
the order in
which pin values
should be
changed to write
data.
Sending LCD Commands
So the RS and
R/W pins must
be set to
appropriate
values first.
Sending LCD Commands
There is a
minimum time
that must elapse
before the next
event.
Sending LCD Commands
However, it takes
non-zero time for
the enable signal
to go HIGH after
setting a PORT
bit.
Sending LCD Commands
So it’s better to
delay at least 1
microsecond
here.
Sending LCD Commands
Finally, we can
change the
values of our
data pins.
Sending LCD Commands
However, since
𝑇𝐷𝐷𝑅 is 360 ns
MAXIMUM, we
cannot change
our data quickly
enough!!
Sending LCD Commands
Nothing wrong
with having it
ready
beforehand.
Timing sequence for a Write to LCD
Sequence
A 4-bit Command
So to send a 4-bit LCD command:
Delay again.
LCD Initialization
Another command
LCD Initialization
Another delay
LCD Initialization
http://web.alfredstate.edu/faculty/weimandn/lcd/lcd_initialization/lcd_initializati
on_index.html
LCD Initialization by instruction - 4 bit interface
void initLCDProcedure()
void initLCD(){
initLCDPins();
initLCDProcedure();
Character strings
When you need to display “words” or
“character strings” on the LCD display
oIn C language you can present this as a “characters
array” and use a “pointer” to point to the array.
oThe pointer is just the address of the first character
in the array, and “pointer +1” is the second character
in the array, “pointer +2” is the third…
oBy passing the pointer to an LCD_write_string
function, you can cite all the characters in the array
in this function and send them one by one and show
them on the screen.
Character strings – LCD write
void LCD_write_string(const char *str)
When you are {
passing a string, its while(*str != '\0'){
better use a string LCD_write(*str);
pointer and str++;
increment the }
pointer, if you are }
incrementing a void LCD_write_string(unsigned char *str)
pointer it will
automatically go the /*store address value of the string in
next address of the pntr *str */
variable in which you {
can store your int i=0;
character which you while(str[i]!=’\0′)
/* loop will go on till the NULL character
wanted to display. in the string */
See two examples { LCD_write(str[i]);
adjacent. // sending data on LCD byte by byte
i++;
}
return;
}