Monday, 21 September 2015

16X2 LCD (LM016L) Programming in PIC (display the message "hello world")



#include<pic.h>
void delay();
void cmd(int);
void data(char);

void main()
{
int i;
char a[]="hello world";
TRISC=0X00;
TRISD=0X00;
cmd(0x38);
cmd(0X0E);
cmd(0X06);
cmd(0X01);
cmd(0X80);

for(i=0;a[i]!='\0';i++)
data(a[i]);
}
void cmd(int s)
{
PORTD=s;
RC0=0;
RC1=0;
RC2=1;
delay();
RC2=0;
}

void data(char a)
{
PORTD=a;
RC0=1;
RC1=0;
RC2=1;
delay();
RC2=0;
}
void delay()
{
int k,j;
for(k=0;k<100;k++)
for(j=0;j<100;j++);
}

No comments:

Post a Comment