glcd 128*64 (ks108)

hello .
i want connect lcd 128*64 to arduino mega
I need wiring and a simple program for this LCD
i attach picture glcd in this topic

I can’t say how illuminating this sketch will prove. It’s not a “library”, it’s just what I came up with while experimenting.

                  // GLCD pin#
const byte DIpin = 2;   //  4
const byte Epin = 3;    //  6
// byte RWpin = 5;
const byte DB0 = 4;     //  7
const byte DB1 = 5;     //  8
const byte DB2 = 6;     //  9
const byte DB3 = 7;     // 10
const byte DB4 = 8;     // 11
const byte DB5 = 9;     // 12
const byte DB6 = 10;    // 13
const byte DB7 = 11;    // 14

byte dbregister;
byte parsebit;
byte bitmask;
byte index;
byte page;
byte yaddr;

byte reverseflag=0;   // 1 = reverse field

byte Sarray[8] = {0,0x46,0x6f,0x49,0x49,0x7b,0x32,0};
byte Uarray[8] = {0,0x3f,0x7f,0x40,0x40,0x7f,0x3f,0};
byte Carray[8] = {0,0x3e,0x7f,0x41,0x41,0x63,0x22,0};
byte Earray[8] = {0,0x7f,0x74,0x49,0x49,0x41,0x41,0};
byte Excl[8] = {0,0,0x5f,0x5f,0,0,0,0};
byte charcolidx;

// ---------------------------

void setup ()
{
  pinMode(Epin,OUTPUT);
  digitalWrite(Epin,HIGH);
  pinMode(DIpin,OUTPUT);
  //pinMode(RWpin,OUTPUT);
  pinMode(DB0,OUTPUT);
  pinMode(DB1,OUTPUT);
  pinMode(DB2,OUTPUT);
  pinMode(DB3,OUTPUT);
  pinMode(DB4,OUTPUT);
  pinMode(DB5,OUTPUT);
  pinMode(DB6,OUTPUT);
  pinMode(DB7,OUTPUT);
  
  Dmode();          // Instruction Mode
  dbregister = 0x3f;  // display ON
  pickandplace();
  clearscreen();  
}

void loop ()
{
  dbregister = 0xb9;  // Set Page [1]       B10111xxx
  pickandplace();
  dbregister = 0x50;  // Set Y address, 16 to the R,  B01xxxxxx
  pickandplace();
  
  message();
}

void latchdb ()   // cycles Epin, GLCD accepts DB0-7 
{
  digitalWrite(Epin,LOW);
  delay(1);       // see if this trip is really necessary
  digitalWrite(Epin,HIGH);
}

void pickandplace ()   // parse out DBREGISTER
{
  bitmask = 1;
  parse();
  digitalWrite(DB0,parsebit);
  parse();
  digitalWrite(DB1,parsebit);
  parse();
  digitalWrite(DB2,parsebit);
  parse();
  digitalWrite(DB3,parsebit);
  parse();
  digitalWrite(DB4,parsebit);
  parse();
  digitalWrite(DB5,parsebit);
  parse();
  digitalWrite(DB6,parsebit);
  parse();
  digitalWrite(DB7,parsebit);  
  
  latchdb();   // cycle Epin to latch data in GLCD
}

void parse ()
{
  parsebit = (dbregister & bitmask);
  if(parsebit > 0)
  { 
    parsebit = 1;
  }
  bitmask = bitmask * 2;   // walk masking bit to left
}

void clearscreen ()
{
  //  set PAGE          INST
  //  set Y addr        INST
  //  do 0's 64 times   DATA
  Imode();          // Instruction Mode
  for(page=0xb8; page<0xc0; page++) // 0xb8 - 0xbf
  {
    dbregister = page;  // Set Page: B10111xxx
    pickandplace();
    Dmode();        // Data Mode
    {
      dbregister = 0;  // data-BLANK
      for(yaddr=0x40; yaddr<0x80; yaddr++) // 0x40-7f
      { 
        pickandplace();
      }
      Imode();      // Instruction Mode 
    }
  }
}
      
void Imode ()
{
  digitalWrite(DIpin,LOW);
}

void Dmode ()
{
  digitalWrite(DIpin,HIGH);
}
  
void Sprint ()
{
  for(charcolidx=0;charcolidx<8;charcolidx++)
  {
    dbregister=Sarray[charcolidx];
    if(reverseflag==1)
    {
      dbregister = ~dbregister;
    }
    pickandplace();
  }
}

void Uprint ()
{
  for(charcolidx=0;charcolidx<8;charcolidx++)
  {
    dbregister=Earray[charcolidx];
    if(reverseflag==1)
    {
      dbregister = ~dbregister;
    }    
    pickandplace();
  }
}

void Cprint ()
{
  for(charcolidx=0;charcolidx<8;charcolidx++)
  {
    dbregister=Carray[charcolidx];
    if(reverseflag==1)
    {
      dbregister = ~dbregister;
    }    
    pickandplace();
  }
}

void Eprint ()
{
  for(charcolidx=0;charcolidx<8;charcolidx++)
  {
    dbregister=Earray[charcolidx];
    if(reverseflag==1)
    {
      dbregister = ~dbregister;
    }    
    pickandplace();
  }
}

void Exprint ()
{
  for(charcolidx=0;charcolidx<8;charcolidx++)
  {
    dbregister=Excl[charcolidx];
    if(reverseflag==1)
    {
      dbregister = ~dbregister;
    }    
    pickandplace();
  }
}

void message ()
{
  Dmode();          // Data Mode
  Sprint();
  Uprint();
  Cprint();
  Cprint();
  Eprint();
  Sprint();
  Sprint();
  Exprint();
  delay(3000);
  if(reverseflag==0)
  {
    reverseflag=1;
  }
  else
  {
    reverseflag=0;
  }
}

The /R pull-up is 1K. The pot is 50K.