//PROGRAM TO DISPLAY " ETALVIS" on line2,rotate right to left continuosly.
//d0-d7 on port f and e and rs on portk
volatile uint8_t *outf,*outk;
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;
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++){//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<250000;k++);
clear_display();
}
while(1){
q=0;z=0;
for(i=0;i<16;i++){//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<250000;k++);
clear_display();
}
}
}
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();
}