Friday, June 8, 2012

How to display text on 16x2 LCD using AVR microcontroller (ATmega16)

This article is in continuation to the article Single character LCD display using AVR. The aforesaid article shows how to display a single letter on LCD. Moving forward towards learning to work with LCD, this article explains how to display a string on LCD. Displaying string is occasionally used in many applications.

The connection of the LCD with the AVR microcontroller (ATmega16) is shown in the circuit diagram. A string is nothing but a sequence of characters. The following steps explain how to display a string on the LCD.
To send string on LCD:
        i.            Make a string pointer variable
       ii.            Pass the starting address of string to that pointer variable
      iii.            Pass the string pointer value to the LCD_write function
      iv.            Increment the pointer value and go to step (iii.) till the value of pointer reaches NULL character.

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;
}
 


No comments:

Post a Comment