#include <pic18.h>
#define ldata PORTD //PORTD = LCD data pins
#define rs PORTBbits.RB0
#define rw PORTBbits.RB1
#define en PORTBbits.RB2
void main()
{
TRISD=0; //both ports B and D as output
TRISB=0;
en=0; //enable idle low
MSDelay(250);
lcdcmd(0x38); //init.LCD 2 lines,5x7 matrix
MSDelay(250);
lcd(0x0E); //desplay on, cursor on
MSDelay(15);
lcdcmd(0x01); //clear LCD
lcdready();
lcdcmd(0x06); //shift cursor right
MSDelay(15);
lcdcmd(0x86); //line 1, position 6
MSDelay(15);
lcddata('M'); //display letter 'M'
MSDelay(15);
lcddata('D'); //display letter 'D'
MSDelay(15);
lcddata('E'); //display letter 'E'
}
void lcdcmd(unsigned char value)
{
ldata = value; //put the value on the pins
rs=0;
rw=0;
en=1; //strbe the enable pin
MSDelay(1);
en=0;
}
void lcddata(unsigned char value)
{
ldata=value; //jput the value on the pins
rs =1;
rw=0;
en=1; //strobe the enable pin
MSDelay(1);
en=0;
}
void MSDelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<135;j++);
} |