4. Displays
LCD displays
Advantages of LCD displays
Pin description of LCD
LCD command codes
Sending commands and data to LCD
Sending 8-bit data to LCD
Programming in ‘C’ language
References
5. If keyboard are the predominant means of interface to human input,
then visible displays are the universal means of human output.
Displays can be grouped in to three broad categories:
1) Single light (e.g. LED Indicators)
2) Single character (e.g. seven segment display)
3) Intelligent alphanumeric (e.g. LCD display)
6. LCD (Liquid Crystal Display) type displays, provide a very
convenient way of displaying information or digital data in the
form of numbers, letters or even alpha-numerical characters.
LCD displays have one major advantage over similar LED types in
that they consume much less power.
Nowadays both LCD and LED displays are combined together to
form larger Dot-Matrix Alphanumeric type displays which can
show letters and characters as well as numbers in standard Red or
Tri-color outputs.
7. LCD’s are finding widespread use replacing seven segment LEDs or
multisegment LEDs. This is due to following reasons:
The declining prices of LCDs.
The ability to display number, character, and graphics.
Incorporation of a refreshing controller into the LCD, thereby
relieving the CPU of the task of refreshing the LCD.
Ease of programming for characters and graphics.
8.
9. Pin No. Name Description
1 VSS Power supply (GND)
2 VCC Power supply (+5V)
3 VEE Power supply to control Contrast
4 RS 0 = Instruction input / 1 = Data input
5 R/W 0 = Write to LCD module / 1 = Read from LCD module
6 EN Enable signal
7 D0 Data bus line 0 (LSB)
8 D1 Data bus line 1
9 D2 Data bus line 2
10 D3 Data bus line 3
11 D4 Data bus line 4
12 D5 Data bus line 5
13 D6 Data bus line 6
14 D7 Data bus line 7 (MSB)
10. Code (Hex) Command to LCD Instruction (Register)
1 Clear display
2 Return home
4 Decrement cursor (shift cursor to left)
6 Increment cursor (shift cursor to right)
5 Shift display right
7 Shift display left
8 Display off, cursor off
A Display off, cursor on
C Display on, cursor off
E Display on, cursor blinking
F Display on, cursor blinking
11. 10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift the entire display to the right
80 Force cursor to beginningof first line
C0 Force cursor to beginning of second line
28
38
19. LCD programming in ‘C’ language
#include<avr/io.h>
#include<util/delay.h>
#define lcd_data PORTA // LCD data port
#define ctrl PORTB
#define en PB2 // enable signal
#define rw PB1 // read or write signal
#define rs PB0 // register select signal
void lcd_cmd(unsigned char cmd);
void init_lcd(void);
void lcd_write(unsigned char data);
20. int main()
{
DDRA=0xFF;
DDRB=0x07;
init_lcd(); // initialization of LCD
_delay_ms(50); // delay of 50ms
lcd_write_string(“Hello"); // prints string on LCD
return 0;
}
void init_lcd(void)
{
lcd_cmd(0x38); // LCD initialization
_delay_ms(1);
lcd_cmd(0x01); // clear LCD
_delay_ms(1);
21. lcd_cmd(0x0E); // cursor ON
_delay_ms(1);
lcd_cmd(0x80); // ---8 go to first line and --0 is for 0th position
_delay_ms(1);
return;
}
void lcd_cmd(unsigned char cmd)
{
lcd_data=cmd;
ctrl =(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
ctrl =(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return;
}
22. void lcd_write(unsigned char data)
{
lcd_data= data;
ctrl = (1<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
ctrl = (1<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return ;
}
void lcd_write_string(unsigned char *str) //store address value of the string in pointer
*str
{
int i=0;
while(str[i]!='0‘) // loop will go on till the NULL character in the string
{
lcd_write(str[i]); // sending data on LCD byte by byte
i++;
}
return;
}
23. AVR microcontroller and embedded system – Muhammad Ali
Mazidi, Sepehr Naimi, and Sarmad Naimi.
The 8051 microcontroller architecture, programming and its
applications – Kenneth J Ayala of Western Carolina University.
http://www.electronics-tutorials.ws/ LCDdisplay/bin_3.html
Editor's Notes
The declining prices of LCDs
The ability to display number, character, and graphics. This is in contrast to LEDs, which are limited to numbers and a few characters.
Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep displaying the data.
Ease of programming for characters and graphics.