/////////////////////////////////////////////////////////////////////////////
void Write_LCD_Data_8(ubyte data)
  {
  //Make register select 1, Make R/W 0=write
  OnRsH();
  OnRwL();
  //Write the data to the port.
  data_register=data;	
  Update_Buttons_From_Data_Register();
  //Strobe enable
  Sleep(1);
  OnEH();
  Sleep(1);
  OnEL();
  }
/////////////////////////////////////////////////////////////////////////////
void Write_LCD_Control_8(ubyte data)
  {
  //Make register select 0, Make R/W 0=write
  OnRsL();
  OnRwL();
  //Write the data to the port.
  data_register=data;	
  //Strobe enable
  Sleep(1);
  OnEH();
  Sleep(1);
  OnEL();
  }
/////////////////////////////////////////////////////////////////////////////
void Init_LCD_8(void)
  {
  //This sequence is from the initialization on page 45 of the HD44780U
  //data sheet.
  Sleep(40);
  Write_LCD_Control_8(0x38);
  //Yes, the data sheet says write it twice.
  Sleep(5);
  Write_LCD_Control_8(0x38);
  //Yes, the data sheet says write it three times.
  Sleep(125);
  Write_LCD_Control_8(0x38);
  //Yes, the data sheet says write it four times, but at least this one counts.
  //038h is Function set:
  //8 bit,
  //2 line
  //F = (5x8)
  Sleep(1);
  Write_LCD_Control_8(0x38);
  //"Display off"
  Sleep(2);
  Write_LCD_Control_8(0x08);
  //"Display clear"
  Sleep(2);
  Write_LCD_Control_8(0x01);
  //006h is Entry mode set, increment, no shift
	Sleep(2);
  Write_LCD_Control_8(0x06);
  //Display on, cursor on, blinking
	Sleep(2);
  Write_LCD_Control_8(0x0F);
  //Clear the display again. This seems to fix a power-up problem
  //where the display shows "{{{{{" in a couple of places.
	Sleep(2);
  Write_LCD_Control_8(0x01);
  }
/////////////////////////////////////////////////////////////////////////////