//PROGRAM TO DISPLAY "WELCOME TO" ON LINE1 MIDDLE AND DISPLAY "ETALVIS" ON LINE2 ROTATING RIGHT TO LEFT
//d0-d7 on port f and e and rs on portk
volatile uint8_t *outf,*outk;
volatile uint8_t arr[]={0X20,0X20,0X20,0x57,0x45,0x4C,0x43,0x4F,0x4D,0x45,0x20,0x54,0x4F,0X20,0X20,0X20};
volatile uint8_t array1[] ={0x20,0x45,0x54,0x41,0x4C,0x56,0x49,0x53,0x20,0x45,0x54,0x41,0x4C,0x56,0x49,0x53};
volatile uint8_t address;
volatile uint8_t j,i,p;
volatile int z=0,q=0;
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;
}
void loop() {
// put your main code here, to run repeatedly:
outf=0x31;outk=0x108;
initialize();
for(i=0;i<16;i++){
//LINE1
for(p=0;p<16;p++){
*outk=0x00;//rs low for command
*outf=0x80+p;//setting cursor
pulse_enable_command();
*outk=0x02;//rs high for data
*outf=arr[p];
pulse_enable_data();
}
//LINE2
//array1 entering
address=0xcf-i;
for(j=0;j<=i;j++){
*outk=0x00;
*outf=address+j;
pulse_enable_command();
if(j==0){//left to right entering
*outk=0x02;
*outf=array1[z];
pulse_enable_data();
}
else{
*outk=0x02;
*outf=array1[z+j];
pulse_enable_data();
}
}
for(k=0;k<100000;k++);
}
while(1){
q=0;z=0;
for(i=0;i<16;i++){
//LINE2
//array1 leaving
address=0xc0;
q++;
for(j=0;j<=14-i;j++){
*outk=0x00;
*outf=address+j;
pulse_enable_command();
if(j==0){//left to right entering
*outk=0x02;
*outf=array1[q];
pulse_enable_data();
}
else{
*outk=0x02;
*outf=array1[q+j];
pulse_enable_data();
}
}
address=0xcf-i;//array2 entering
for(j=0;j<=i;j++){
*outk=0x00;
*outf=address+j;
pulse_enable_command();
if(j==0){//left to right entering
*outk=0x02;
*outf=array1[z];
pulse_enable_data();
}
else{
*outk=0x02;
*outf=array1[z+j];
pulse_enable_data();
}
}
for(k=0;k<100000;k++);
}
}
}
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();
}