//PROGRAM TO DISPLAY "WELCOME" ON LINE1.ENTER FROM LEFT,STAY ON MIDDLE.
//AND TO DISPLAY "TO ETALVIS" ON LINE2.ENTER FROM RIGHT,STAY ON MIDDLE.
//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 uint8_t arr2[]={0x54,0x6F,0x20,0x45,0x54,0x41,0x4C,0x56,0x49,0x53};
volatile uint8_t address;
volatile uint8_t j,i;
volatile uint32_t 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();
//LINE2
for(i=0;i<12;i++){
address=0xcF-i;
for(j=0;j<=i;j++){
*outk=0x00;
*outf=address+j;
pulse_enable_command();
if(j<=9){
*outk=0x02;
*outf=arr2[j];
pulse_enable_data();
}
else{
*outk=0x02;
*outf=0x20;
pulse_enable_data();
}
}
//LINE1
address=0x80+i;
for(j=0;j<=i;j++){
*outk=0x00;
*outf=address-j;
pulse_enable_command();
if(j<=6){
*outk=0x02;
*outf=arr[6-j];
pulse_enable_data();
}
else{
*outk=0x02;
*outf=0x20;
pulse_enable_data();
}
}
for(k=0;k<100000;k++);
if(i<11) clear_display();
}
}
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();
}