//my first own writing pro(19-03-23)
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_data("  AARAV");
}
void write_data(char *ptr)
{
  while(*ptr!=0)
  {
    write_data(*ptr);
    delay1(10);
    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(0x07); //Entry mode
  lcd_countral_write();
//-------------------------------------------
//2 line left display
   outdata(0x18);// Cursor or Display shift
  lcd_countral_write();
  outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
  outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
  outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
  outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
 
  
  //-------------------------------------
  //2 line middle- display
  outdata(0x1C);// Cursor or Display shift
  lcd_countral_write();
  outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
    outdata(0x14);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x1C);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x14);// Cursor or Display shift
  lcd_countral_write();
  outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
    outdata(0x14);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x1C);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x14);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x14);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   //----------------------------------------
   //2 line Right justified
   outdata(0x1c);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x14);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x1c);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x14);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x1c);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x14);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
   outdata(0x1C);// Cursor or Display shift
   lcd_countral_write();
    outdata(0x10);// Cursor or Display shift
   lcd_countral_write();
    outdata(0x1C);// Cursor or Display shift
    lcd_countral_write();
     outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
    outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x14);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x1C);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
  lcd_countral_write();
   outdata(0x10);// Cursor or Display shift
  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(0x01);
  delay1(1);
  outcountrol(0x00);
  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:

}
mega:SCL
mega:SDA
mega:AREF
mega:GND.1
mega:13
mega:12
mega:11
mega:10
mega:9
mega:8
mega:7
mega:6
mega:5
mega:4
mega:3
mega:2
mega:1
mega:0
mega:14
mega:15
mega:16
mega:17
mega:18
mega:19
mega:20
mega:21
mega:5V.1
mega:5V.2
mega:22
mega:23
mega:24
mega:25
mega:26
mega:27
mega:28
mega:29
mega:30
mega:31
mega:32
mega:33
mega:34
mega:35
mega:36
mega:37
mega:38
mega:39
mega:40
mega:41
mega:42
mega:43
mega:44
mega:45
mega:46
mega:47
mega:48
mega:49
mega:50
mega:51
mega:52
mega:53
mega:GND.4
mega:GND.5
mega:IOREF
mega:RESET
mega:3.3V
mega:5V
mega:GND.2
mega:GND.3
mega:VIN
mega:A0
mega:A1
mega:A2
mega:A3
mega:A4
mega:A5
mega:A6
mega:A7
mega:A8
mega:A9
mega:A10
mega:A11
mega:A12
mega:A13
mega:A14
mega:A15
lcd1:VSS
lcd1:VDD
lcd1:V0
lcd1:RS
lcd1:RW
lcd1:E
lcd1:D0
lcd1:D1
lcd1:D2
lcd1:D3
lcd1:D4
lcd1:D5
lcd1:D6
lcd1:D7
lcd1:A
lcd1:K