//PROGRAM TO DISPLAY WELCOME ON LINE2,RIGHT JUSTIFIED.
//d0-d7 on port f and e and rs on portk
volatile uint8_t *outf,*outk;
volatile uint8_t arr[]={0x57,0x45,0x4C,0x43,0x4F,0x4D,0x45};
volatile long j,i;
void setup() {
// put your setup code here, to run once:
volatile uint8_t *dirf,*dirk;
dirf=0x30,dirk=0x107;
*dirf=0xff;*dirk=0x03;
outf=0x31;outk=0x108;
initialize();
*outk=0x00;//rs low for command
*outf=0xcf;//setting cursor at line2 right
*outk=0x01;// e high
for(j=0;j<1000;j++);
*outk=0x00;// e low
*outk=0x02;//rs high for data
for(i=6;i>=0;i--){
*outf=arr[i];
*outk=0x03;
for(j=0;j<1000;j++);
*outk=0x02;
}
}
void loop() {
// put your main code here, to run repeatedly:
}
void initialize(){
for(j=0;j<10000;j++);//15ms wait
//function set 2lines and 8 columns
*outk=0x00;// using lcd in command mode
*outf=0x38;//putting data
*outk=0x01;//pulsing e
for(j=0;j<1000;j++);
*outk=0x00;
//turning the display ON
*outk=0x00;// using lcd in command mode
*outf=0x0c;//putting data
*outk=0x01;//pulsing e
for(j=0;j<1000;j++);
*outk=0x00;
//clearing display
*outk=0x00;// using lcd in command mode
*outf=0x01;//putting data
*outk=0x01;//pulsing e
for(j=0;j<1000;j++);
*outk=0x00;
//cursor setting to move one time towards right after display one character
*outk=0x00;// using lcd in command mode
*outf=0x04;//putting data for right side cursor
*outk=0x01;//pulsing e
for(j=0;j<1000;j++);
*outk=0x00;
}