void init_port(void);
void outdata(char);
void outcountrol(char);
void init_lcd(void);
void write_data(char);
void lcd_countral_write(void);
void delay1(int);
void setup() {
     init_port();
     init_lcd();
     write_string("megan");
}
 void write_string(char*ptr)
 {
   while(*ptr!=0)
   {
     write_data(*ptr);
     ptr++;
   }
 }
void init_port()
{
  volatile char *portf_dir=(volatile char*)0x30;
  volatile char *portk_dir=(volatile char*)0x107;
  *portf_dir=0xFF;
  *portk_dir=0x03;
}
void outdata(char out_data)
{
  volatile char *portf_data=(volatile char*)0x31;
  *portf_data=out_data;
}
void outcountrol(char out_data)
{
  volatile char *portk_data=(volatile char*)0x108;
  *portk_data=out_data;
}
 void init_lcd(void)
 {
   outdata(0x38); // * bit 2 Line function set
  lcd_countral_write();
  outdata(0x0F); // Display on/off Control
  lcd_countral_write();
  outdata(0x01); // Clear display
  lcd_countral_write();
  outdata(0x06); //Entry mode
  lcd_countral_write();
  //---------------------------
   outdata(0x14);
   lcd_countral_write();

 }
 void write_data(char wr_data)
 {
   outdata(wr_data);
   outcountrol(0x02);
   delay1(1);
   outcountrol(0x03);
   delay1(1);
   outcountrol(0x02);
   delay1(1);
 }
 void lcd_countral_write(void)
 {
   outcountrol(0x00);
   delay1(1);
   outcountrol(0x01);
   delay1(1);
 }
 void delay1(int count)
 {
   volatile long i;
   while(count)
   {
     for(i=0;i<1000;i++);
     count--;
   }
 }
void loop() {
  // put your main code here, to run repeatedly:

}