//PROGRAM TO DISPLAY WELCOME ON LINE2,MIDDLE.
//d0-d7 on port f and e and rs on portk
volatile uint8_t *outf,*outk;
volatile uint8_t arr[]={0x20,0x20,0x20,0x20,0x57,0x45,0x4C,0x43,0x4F,0x4D,0x45,0x20,0x20,0x20,0x20,0x20};
volatile long j,i,k;
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=0xc0;//setting cursor at line2 middle
pulse_enable_command();
*outk=0x02;//rs high for data
for(i=0;i<16;i++){
*outf=arr[i];
pulse_enable_data();
}
}
void loop() {
// put your main code here, to run repeatedly:
}
void initialize(){
for(k=0;k<10000;k++);//15ms wait
//function set 2lines and 8 columns
*outk=0x00;// using lcd in command mode
*outf=0x38;//putting data
pulse_enable_command();
//turning the display ON
*outk=0x00;// using lcd in command mode
*outf=0x0c;//putting data
pulse_enable_command();
//clearing display
clear_display();
}
void pulse_enable_data(){
*outk=0x03;//pulsing e
for(k=0;k<100;k++);
*outk=0x02;
}
void pulse_enable_command(){
*outk=0x01;//pulsing e
for(k=0;k<100;k++);
*outk=0x00;
}
void clear_display(){
*outk=0x00;// using lcd in command mode
*outf=0x01;//putting data
pulse_enable_command();
}