How to use an LCD module?
LCD or Liquid Crystal Display is nowadays fast becoming a preferred choice for an interface device due to its ease of use,cheap rates and value for money performance.
They are available in various specs 16X1 16
LCD or Liquid Crystal Display is nowadays fast becoming a preferred choice for an interface device due to its ease of use,cheap rates and value for money performance.
They are available in various specs 16X1 16X2 20X2 etc�
The first number denotes the number of characters/line and second denotes the number of lines.
The most widely used LCDs are based on the HITACHI HD44780 controller.
It has 16 pins arranged in the following configuration:
1 � Vss
2 � Vcc
3 � Vee
4 � RS
5 � R/W
6 � EN
7 � DB0
8 � DB1
9 � DB2
10- DB3
11 � DB4
12 � DB5
13 � DB6
14 � DB7
15 � LED+
16 � LED-
* DB0-DB7: Data Pins
* RS: 1 � Data 0 � Command
* R/W: 1 � Read 0 – Write
* EN: To be Pulsed when to execute any operation
* Vee: Contrast Adjust Pin
We will be using the LCD in 4 bit mode. This amounts to using 7(3 control signals and 4 for data) bits for controlling the
LCD instead of the normal 11.
In 4 bit mode the DB4-DB7 data lines are used for writing data. The upper nibble of data is sent first and then the lower
nibble of data is sent. In 8 bit mode the whole byte is sent at once.
LCD command library (Courtesy Team TRI):
LCD_INIT()
Initializes the LCD in 2 line 4 bit mode with blinking cursor.
LCD_WRITE(�X�)
Used to write any character X to the LCD.
LCD_STRING(�Xplore Robotics�)
Used to write a string on the LCD (max 16 characters in length)
LCD_CMD(X)
To give commands to the LCD. X can be as follows
PUTLINE1 � Places cursor on line1
PUTLINE2 – Places cursor on line2
DISPON � Turns display on
To place the cursor on a particular character box it is addressed as follows:
Command = LCD_CMD(0b1XXX XXXX);
where xxx xxxx is the address of character in binary.
Note: LCD row 1 address starts at 0×00 and row 2 starts at 0×40
Eg: To put cursor on 3 character line 1
LCD_CMD(0×83);
To put cursor on 5 character line 2
LCD_CMD(0xC5);
LCD_CLEAR()
Clears LCD screen.
Sample Program:
#include”REG52MOD.h”
#include�LCD.h�
void main (void)
{
LCD_INIT();
LCD_STRING(�Hello World�);
while(1){}
}
No prizes for guessing what THIS program is supposed to do!!!!
Let�s move onto something higher
#include”REG52MOD.h”
#include�LCD.h�
void main (void)
{
LCD_INIT();
LCD_STRING(�USING�);
LCD_CMD(PUTLINE2);
LCD_STRING(”LCD”);
delay(100);
LCD_CLEAR();
LCD_CMD(0×83);
LCD_STRING(”IS”);
LCD_CMD(0xC5);
LCD_STRING(”COOL”);
while(1){}
}
Having fun aren�t we???
I think I should end this tutorial here and leave you with things to experiment .Some good pages to visit for inside
information about the working of an LCD are
http://www.myke.com/lcd.htm
http://www.geocities.com/dinceraydin/lcd/index.html (you�ll find a nice cool LCD simulator on this page)
2 Comments on “How to use an LCD module?”
Мде …
Я извиняюсь, но, по-моему, Вы ошибаетесь. Давайте обсудим это. Пишите мне в PM, пообщаемся….
Не могу сейчас поучаствовать в обсуждении – нет свободного времени. Но освобожусь – обязательно напишу что я думаю по этому вопросу….
LCD or Liquid Crystal Display is nowadays fast becoming a preferred choice for an interface device due to its ease of […….