Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sitarambhai Naranjibhai Patel Institute of Technology and Research Centre, Umrakh, Bardoli. A Presentation On “ 16x2 LCD Interfacing with AVR atmega32.

Similar presentations


Presentation on theme: "Sitarambhai Naranjibhai Patel Institute of Technology and Research Centre, Umrakh, Bardoli. A Presentation On “ 16x2 LCD Interfacing with AVR atmega32."— Presentation transcript:

1 Sitarambhai Naranjibhai Patel Institute of Technology and Research Centre, Umrakh, Bardoli. A Presentation On “ 16x2 LCD Interfacing with AVR atmega32 microcontroller ” Under subject of Microcontroller & Interfacing,B.E. : Sem – 5 (Electronics and Communication Branch)

2 Prof. Vipul Mistry Guided By : Prof. Vipul Mistry Prof. Krunal Yadav Head of Department: Prof. Vinesh Kapadia Submitted by: Group: 5 Sr. No.Name Of Student Enrollment No. 1Bhagtani Namrata 130490111001 2Pathan Farhin130490111022 3Savaliya Juhi130490111027 4Shroff Megha130490111030

3 Introduction This presentation includes what LCD is and how to interface LCD with AVR microcontroller Atmega32 using 8-bit mode. What is the basic difference between 8-bit mode and 4-bit mode? How to write code for LCD interfacing in C language and what are the basic commands used for LCD programming. It also includes how to program LCD and sends command/ data to LCD.

4 Hardware requirements: Atmega32 ic 16x2 lcd display Breadboard 8Mhz crystal oscillator Power supply Software requirements: AVR studio 4 Proteus 7

5 WHAT IS LCD? LCD stands for Liquid Crystal Display, 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.

6 PIN DESCRIPTION OF LCD 16X2 LCD can interface with AVR microcontroller by using two modes, 4-bit mode or 8-bit mode. Here we will use 8-bit mode for interfacing. In 8-bit mode we send command to LCD by using eight data lines (D0-D7) while in 4-bit mode we use four data lines (D5-D7) for sending command and data. These data lines can be connected to any port of Atmega32.

7 PIN NO.PIN NAMEDESCRIPTION 1V CC Supply pin (+5V DC) 2V DD Ground pin 3V EE Contrast pin 4RS Register selection pin (either data or command)RS=0: Command Register, RS=1: Data Register

8 PIN NO.PIN NAMEDESCRIPTION 5RW Selects Read or Write operationRW=0: for write RW=1: for read 6EEnable pin 7D0Data pin 0 8D1Data pin 1 9D2Data pin 2 10D3Data pin 3 11D4Data pin 4 12D5Data pin 5 13D6Data pin 6 14D7Data pin 7

9 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.

10 SENDING COMMANDS ON LCD For sending commands on LCD we have to write command on data pins. For this, selects: RS = 0 >> selects command register RW = 0 >> selects write operation E>> make enable pin from high to low

11 SENDING DATA ON LCD 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 E >> make enable pin from high to low

12 CODE FOR INTERFACING LCD #include command_write (unsigned char); data_write (unsigned char); ready(); main(); delay(); { unsigned char command[]={0x38,0x01,0x0e,0x06,0x80}; unsigned char data[]={'V','B','I','T'}; unsigned char i; DDRA=0xFF; // configure port A as output port DDRB=0x07; // configure port B as output port

13 for(i=0;i<=4;i++) // for loop execution 4 times { command_write(command[i]); //command write from unsigned char command _delay_ms(2); // 2ms delay } for(i=0;i<=7;i++) //for loop execution 7 times { data_write(data[i]); // data write from unsigned char data } }

14 //subroutine command_write (unsigned char m) { _delay_ms(5); //5ms delay PORTA=m; // port A is equal to unsigned char m PORTB=PORTB & 0xFE; //logical END between port B and 0xFE PORTB=PORTB & 0xFD;//logical END between port B and 0xFE PORTB=PORTB |0x04; //logical OR between port B and 0x04 _delay_ms(2); //2ms delay PORTB=PORTB & 0xFB; //logical AND between port B and 0xFD }

15 data_write(unsigned char n) { _delay_ms(5); //5ms delay PORTA=n; // port A is equal to unsigned char n PORTB=PORTB | 0x01; //logical OR between port B and 0x01 PORTB=PORTB & 0xFD; //logical AND between port B and 0xFD PORTB=PORTB | 0x04; //logical OR between port B and 0x04 _delay_ms(2); //2ms delay PORTB=PORTB & 0xFB; //logical AND between port B and 0xFD }

16 Void ready() { DDRB=DDRA & 0xFF; //logical END between DDRA and 0xFF PORTB=PORTB & 0xFE //logical END between port B and 0xFE PORTB=PORTB | 0x02; //logical OR between port B and 0x02 PORTB=PORTB & 0xFB; //logical END between DDRA and 0xFB _delay_ms(2); //2ms delay PORTB=PORTB | 0x04; //logical OR between port B and 0x04 while( PORTB&0x08); // while loop execution and logical AND between port B and 0x08 DDRA=DDRA|0x01; //logical END between DDRA and 0x01 }

17 SIMULATION ON PROTEUS Compile the above code and dump the HEX file in AVR microcontroller. Make necessary settings and check the display on LCD.

18 SCHEMATIC We design our circuit on proteus. Circuit diagram is given below :

19 BASIC COMMANDS USED IN LCD DISPLAY COMMANDSDESCRIPTION 0x01Clear screen 0x02return home 0x04Cursor decrement 0x05Display shifts to right 0x07Display shifts to left 0x08Cursor and display OFF 0x10 Cursor position Shifts to left 0x14 Cursor position shifts to right

20 COMMANDSDESCRIPTION 0x80 Move cursor to the beginning of first line 0x0CDisplay ON, cursor OFF 0XC0 Move cursor to the beginning of second line 0x0ADisplay OFF, cursor ON 0x0EDisplay ON, cursor blinking 0x30For display in one line in 8-bit mode 0x20For display in one line in 4-bit mode 0x0FDisplay data on cursor blinking 0x18Shift complete data to left side 0x38Using two lines, 8-bit mode 0x28Using two lines, 4-bit mode

21 Thank you


Download ppt "Sitarambhai Naranjibhai Patel Institute of Technology and Research Centre, Umrakh, Bardoli. A Presentation On “ 16x2 LCD Interfacing with AVR atmega32."

Similar presentations


Ads by Google