LCD Control using UART Serial Port
Introduction:

AVR GCC CODE
/*
Purpose:It will take input from the terminal and writes that on LCD
Hardware:
ATmega8 @ 16MHz
PC Software : Hyper terminal @ 19200 baud
No Parity,1 Stop Bit,
Flow Control = NONE
*/
#include
#include
#include
#include
#include "uart.h"
#include "lcd.h"
static int uart_putchar(char c, FILE *stream);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);
static int uart_putchar(char c, FILE *stream)
{
if (c == 'n')
uart_putchar('r', stream);
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
int main()
{
stdout = &mystdout;
//Initialize the LCD Module.
LCDInit(LS_BLINK|LS_ULINE);
LCDClear();
//USART Initialisation 19200bps @ 16MHz crystal USARTInit(51);
char str[20],data; int i=0; while(1) { printf("n PLEASE ENTER THE STRING : "); for(i=0;;i++) { data = USARTReadChar();//saving the given string
USARTWriteChar(data);
str[i]= data;
if((str[i]=='n') ||( str[i]=='r'))
{
str[i]='�';
break;
}
}
LCDClear();
LCDWriteString(str);//displaying the saved string
printf("n Finished n"); _delay_ms(1000); } }
Implementation:
Open the hyperterminal in your computer. Set the settings as per the code. Then reset your microcontroller. You will see "enter the string : ". Enter the text and press ENTER key. You will get "Finished". You will see the text you entered on the display.
Downloads:
Files related to this project. Click here to download
NEXT VERSION:
The text will display only when you enter the text from terminal. I am developing this code for new options. In the later version of this project, the entered text is saved in the EEPROM and if you change the code directly from the terminal.



Comments
Post a Comment