Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIVERSAL COLLEGE OF ENGINEERING & TECHNOLOGY

Similar presentations


Presentation on theme: "UNIVERSAL COLLEGE OF ENGINEERING & TECHNOLOGY"— Presentation transcript:

1 UNIVERSAL COLLEGE OF ENGINEERING & TECHNOLOGY

2 Microcontroller & Interfacing
E.C Engg. Parmar Ramendra ( ) Guided by :- Prof. Parth Patel (E.C Department)

3 LCD (Liquid Crystal Display ) Interfacing with ATmega32

4 What is LCD ? LCD stands for Liquid Crystal Display, it is an electronic device which is used for data display. LCDs are preferable over seven segments and LEDs as they can easily represent data in form of alphabets, characters, numbers or animations. LCDs are very easy to program and make your work quite attractive and simple. Numerous types of LCDs are available in market such as 16X2, 16X4, 20X2, 20X4, graphical LCDs (128X64) etc. The LCD which we are using is 16X2 alphanumeric LCD, it display 32 characters in two rows means in one row we have 16 characters.

5 Pin Description of LCD Pins Symbol Functions 1 Vss Supply pin (+5V DC)
2 Vdd Ground pin 3 VEE Contrast pin 4 RS Register selection pin (Either Data or Command) RS=0 Command register RS=1 Data register 5 RW Selects Read or Write operation RW=0 Write operation RW=1 Read operation 6 E Enable pin

6 Pin Description of LCD Pins Symbol Functions 7 DB0 Data bus bit 0 8
9 DB2 Data bus bit 2 10 DB3 Data bus bit 3 11 DB4 Data bus bit 4 12 DB5 Data bus bit 5 13 DB6 Data bus bit 6 14 DB7 Data bus bit 7 (Also used as Busy pin)

7 How to Program LCD ? Basically there are two registers, command and data. When we are giving command to LCD, we select command register and when we are sending data to LCD for display, we select data register. Command is an instruction given to LCD in order to perform required function according to the given command. In order to display textual information, data is send to LCD.

8 Sending Commands & Data on LCD
For sending commands on LCD we have to write command on data pins. For this, selects: RS = 0 selects command register RW = 1 selects write operation E = make enable pin from high to low Sending Data :- For sending data on LCD we have to write data on data pins. For this, selects: RS = 1 selects data register RW = 0 selects write operation

9 LCD Interfacing circuit with ATmega32

10 Code for interfacing LCD
We use Atmel studio 6 for development of code and the code is written in C language. #include<avr/io.h> #include<util/delay.h> #define LCD_data PORTA #define ctrl PORTB #define en PB2 #define rw PB1 #define rs PB0

11 Continue…. void LCD_cmd(unsigned char cmd); void init_LCD (void); void LCD_write(unsigned char data); void LCD_write_string(); unsigned int press; int main (void) { DDRA=0XFF; DDRB=0X07; init_LCD(); LCD_write_string("Ramendra Parmar");

12 Continue…. LCD_cmd(0xc0); return 0; } void init_LCD(void) { LCD_cmd(0x38); _delay_ms(1);

13 Continue…. _delay_ms(1); LCD_cmd(0x38); LCD_cmd(0x06); LCD_cmd(0x0c); LCD_cmd(0x01);

14 Continue…. LCD_cmd(0x02); _delay_ms(1); return ; } void LCD_cmd(unsigned char cmd) { PORTA=cmd; ctrl=(0<<rs)|(0<<rw)|(1<<en); ctrl=(0<<rs)|(0<<rw)|(0<<en); _delay_ms(150);

15 Continue…. return; } void LCD_write(unsigned char data) { PORTA=data; ctrl=(1<<rs)|(0<<rw)|(1<<en); _delay_ms(1); ctrl=(1<<rs)|(0<<rw)|(0<<en); _delay_ms(150);

16 Continue…. void LCD_write_string(unsigned char *str) { int i=0; while(str[i]!='\0') LCD_write(str[i]); i++; } return;

17 Basic commands used in LCD display
Hex Command Functions 0x01 Clear screen 0x02 return home 0x04 Cursor decrement 0x05 Display shifts to right 0x06 Cursor increment 0x07 Display shifts to left 0x08 Cursor and display OFF 0x10 Cursor position Shifts to left 0x14 Cursor position shifts to right

18 Basic commands used in LCD display
Hex Command Functions 0x80 Move cursor to the beginning of first line 0x0C Display ON, cursor OFF 0XC0 Move cursor to the beginning of second line 0x0A Display OFF, cursor ON 0x0E Display ON, cursor blinking 0x30 For display in one line in 8-bit mode 0x20 For display in one line in 4-bit mode 0x18 Shift complete data to left side 0x1C Shift complete data to right side

19 Thank You….


Download ppt "UNIVERSAL COLLEGE OF ENGINEERING & TECHNOLOGY"

Similar presentations


Ads by Google