You are on page 1of 8

LCD INTERFACING

LCD INTERFACING WITH PIC


It is a 16x2 Alphanumeric LCD with two rows of 16
characters in each row

Basic LCD commands

0x06 - Entry mode

0x0E - Display on cursor on


0x01 - To clear display
0x38 - 5x7 matrix pixel
0x80 - select first row first character
0xc0 - select second row first character
0x0c - display on cursor off

#include<pic.h>
#define RS RC0
#define RW RC1
#define EN RC2
void delay();
void cmd();
void data();
int i,j,k;
char s[]={KELTRON"};
void main()
{
TRISD=0X00;
TRISC=0X00;

cmd();
While(1)
{
for(k=0;k<7;k++)
{
PORTD=s[k];
data();
delay();
}} }
void delay()
{
for(j=0;j<300;j++)
{} }

void cmd()
{
char a[]= {0x38,0x0c,0x01,0xc0};
for(i=0;i<4;i++)
{
PORTD=a[i];
RS=0;
RW=0;
EN=0;
delay();
EN=1;
}
}

void data()
{
RS=1;
RW=0;
EN=0;
delay();
EN=1;
}

SIMULATION IN PROTEUS

You might also like