Interfacing between Atmega 16/32 with LCd 16×2- Tutorial Lecture-2

In our second lecture, we describe the connectivity between
LCD 16×2 with ATmel Atmega16 Microcontroller.
Firstly, we have to know about the LCD, A 16×2 LCD means it’s having 16 rows & 2 columns,
that can display 16 characters per line & there are 2 such lines.
In this LCD, each
character is displayed in 5×7 pixel matrix. This LCD has two registers,
LCD 16×2 pin described in table image below,
The table of LCD 16×2 is show in the image geiven below. The image contain the description of all LCD pin.
The connectivity is shown in the figure below.

After we finish the hardware connectivity, we move for
programming. We write the program in the AVR studio 4 professional programming
window. We start the program as we write for glowing the led from header file. We
include the header files first.
We provide the demo code for LCD 16×2 for ATmel Atmega
series, written below-
#include<avr/io.h>
#include<util/delay.h>
#include”lcd.h”
// program to lcd display using for loop
void main()
{
InitLCD(0); // for initializing the LCD internal resister
unsigned char i;
LCDClear(); // clear the LCD
LCDWriteStringXY(0,0, “System is”);  // write the string in LCD first row
LCDWriteStringXY(1,0, “booting up “);  // write the string in LCD second row
for(i=0; i<=100; i++)                        //for
loop
{
LCDWriteIntXY(12,1,i,3);   
// for 0 to 100 counting display in lcd
LCDWriteStringXY(15,1,”%”); //for % sign
_delay_ms(50);
}
LCDClear();
LCDWriteString(“Please wait…”);
_delay_ms(1000);
LCDClear();
LCDWriteString(“Schematics”);
LCDWriteStringXY(0,1,”Micro Electronics”);
}
The output of this is program is as shown in the image below
Please note that we use external header & source file (lcd.c
& lcd.h) to operate the LCD commands & execute them.
for any queries & support, feel free to contact
us at www.smedehradun.com or write message to our facebook page or our
blog http://schematicslab.blogspot.in/